How to reset index in Pandas

You can reset the index in Pandas with the following code. I highly recommend you This book to learn Python.

Step 1: Install Pandas Library

Install the Pandas library using this code, if it is not installed.

Python

Example

In this example, I will reset the index of Pandas DataFrame using df.reset_index().

Python

Output:

    Students  Scores
A        Ali      94
B      Amini      93
C  Alexandar      83
D       John      95
    Students  Scores
0        Ali      94
1      Amini      93
2  Alexandar      83
3       John      95

Free Learning Resources

Leave a Comment

Your email address will not be published.