1

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?

3
  • 1
    Use df.index[1] Commented Jan 29, 2019 at 10:43
  • You should use df.index Commented Jan 29, 2019 at 10:44
  • 1
    try d.iloc[1].name this will return 104 Commented Jan 29, 2019 at 11:47

2 Answers 2

2

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

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

Comments

0

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

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.