Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get list of rows of pandas dataframe in python? [duplicate]

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.

like image 492
Bryan McGill Avatar asked Oct 25 '25 15:10

Bryan McGill


2 Answers

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.

like image 200
Rheatey Bash Avatar answered Oct 28 '25 16:10

Rheatey Bash


Try the attribute index

df.index.values
like image 35
David Sidarous Avatar answered Oct 28 '25 17:10

David Sidarous



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!