Tag: How To Get The Index Of A DataFrame?


  • How To Get The Index Of A DataFrame?

    How To Get The Index Of A DataFrame?

    How To Get The Index Of A DataFrame? Table Of Contents: Syntax Of Index Of DataFrame. Examples To Get The Index. (1) Syntax: pandas.DataFrame.index pandas.DataFrame.index.values Description: It will get you the index (row labels) of the DataFrame. (2) Examples Of Index : Example-1 import pandas as pd student = {‘Name’:[‘Subrat’,’Abhispa’,’Arpita’,’Anuradha’,’Namita’], ‘Roll_No’:[100,101,102,103,104], ‘Subject’:[‘Math’,’English’,’Science’,’History’,’Commerce’], ‘Mark’:[95,88,76,73,93]} student_object = pd.DataFrame(student) student_object Output: student_object.index Output: RangeIndex(start=0, stop=5, step=1) Note: Here you can see that, index starts from ‘0’ and stops at ‘5’, and the number of steps it increase is by ‘1’. Getting All The Index Values. student_object.index.values Output: array([0, 1, 2, 3, 4], dtype=int64)

    Read More