How to select the last column of dataframe

pandas, python

Solution

Use iloc and select all rows (`:`) against the last column (`-1`):

df.iloc[:,-1:]

Problem

I have done some searching for the answer to this question, but all I can figure out is this: ``` df[df.columns[len(df.columns)-1]] ``` which to me seems unweildy, and un-pythonic (and slow?). What is the easiest way to select the data for the last column in a pandas dataframe without specifying the name of the column?

Original source

Related problems