Jianhao
Jianhao

Reputation: 91

pandas dataframe : get the index of a given row

I have a dataframe like below:

d = pandas.DataFrame({1:{1,2,3}}, index={0:{103,104,105}})

I want to get the index of a given row. For example, the index of df.iloc[1] should be 104. How can I do that?

Upvotes: 1

Views: 136

Answers (2)

Karn Kumar
Karn Kumar

Reputation: 8816

You must read the pandas.dataframe.index documentation for the deep insight. Or pandas.DataFrame.index nice documentation itself.

Upvotes: 0

Veit Stooss
Veit Stooss

Reputation: 64

You can use df.index[i] where i is the number of the row you want starting from 0.

Upvotes: 2

Related Questions