Nathan Miller Nathan Miller - 1 year ago 162
Python Question

How to select the last column of dataframe

I have done some searching for the answer to this question, but all I can figure out is this:


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?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download