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.

2
  • you mean df.index? Commented May 11, 2019 at 17:55
  • 1
    You're looking for df.values Commented May 11, 2019 at 17:56

2 Answers 2

7

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.

Sign up to request clarification or add additional context in comments.

Comments

5

Try the attribute index

df.index.values

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.