4

How do I get a list of row lables in pandas?

I have a table with column labels and row labels. To return the column lables I use the dataframe "column" attribute. It is possible to return the list of column labels with the attribute columns, but i couldn't find similiar attributes for rows.

Bryan McGill
  • 237
  • 1
  • 2
  • 8

2 Answers2

6

This should work. df.index.values This returns index in the form of numpy array numpy.ndarray, run this type(df.index.values) to check.

Rheatey Bash
  • 779
  • 6
  • 17
5

Try the attribute index

df.index.values
David Sidarous
  • 1,202
  • 1
  • 10
  • 25