Pandas - How to reset index in a given DataFrame Last Updated : 25 Aug, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report Let us see how to reset the index of a DataFrame after dropping some of the rows from the DataFrame.Approach : Import the Pandas module.Create a DataFrame.Drop some rows from the DataFrame using the drop() method.Reset the index of the DataFrame using the reset_index() method.Display the DataFrame after each step. Python3 # importing the modules import pandas as pd import numpy as np # creating a DataFrame ODI_runs = {'name': ['Tendulkar', 'Sangakkara', 'Ponting', 'Jayasurya', 'Jayawardene', 'Kohli', 'Haq', 'Kallis', 'Ganguly', 'Dravid'], 'runs': [18426, 14234, 13704, 13430, 12650, 11867, 11739, 11579, 11363, 10889]} df = pd.DataFrame(ODI_runs) # displaying the original DataFrame print("Original DataFrame :") print(df) # dropping the 0th and the 1st index df = df.drop([0, 1]) # displaying the altered DataFrame print("DataFrame after removing the 0th and 1st row") print(df) # resetting the DataFrame index df = df.reset_index() # displaying the DataFrame with new index print("Dataframe after resetting the index") print(df) Output : Comment More infoAdvertise with us Next Article Pandas DataFrame.reset_index() A ajaynair710 Follow Improve Article Tags : Python Python-pandas Python pandas-dataFrame pandas-dataframe-program Practice Tags : python Similar Reads Reset Index in Pandas Dataframe Letâs discuss how to reset the index in Pandas DataFrame. Often We start with a huge data frame in Pandas and after manipulating/filtering the data frame, we end up with a much smaller data frame. When we look at the smaller data frame, it might still carry the row index of the original data frame. 6 min read Pandas DataFrame.reset_index() The reset_index() method in Pandas is used to manage and reset the index of a DataFrame. It is useful after performing operations that modify the index such as filtering, grouping or setting a custom index. By default reset_index() reverts to a clean, default integer-based index (0, 1, 2, ...) which 4 min read How to drop rows in Pandas DataFrame by index labels? Dropping rows in a Pandas DataFrame by index labels is a common operation when you need to remove specific rows based on their index positions. For example, we are working with a DataFrame that contains details of students, including their names, ages, and universities. Initially, the DataFrame has 5 min read How to Reference the Next Row in a Pandas DataFrame To reference the next row in a Pandas DataFrame, you can use the .shift() method. This method shifts the data by a specified number of periods (rows), allowing you to access the previous or next row's values in a given column. It's useful for comparing consecutive rows or calculating differences bet 4 min read How to Reverse Row in Pandas DataFrame? In this article, we will learn how to reverse a row in a pandas data frame using Python. With the help of Pandas, we can perform a reverse operation by using loc(), iloc(), reindex(), slicing, and indexing on a row of a data set. Creating Dataframe Letâs create a simple data frame with a dictionar 3 min read How to reset index after Groupby pandas? In pandas, groupby() is used to group data based on specific criteria, allowing for operations like aggregation, transformation and filtering. However, after applying groupby(), the resulting DataFrame often has a MultiIndex or a non-sequential index, which can make data handling more complex. Reset 3 min read Like