Pandas - How to reset index in a given DataFrame Last Updated : 25 Aug, 2021 Comments Improve Suggest changes 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 - How to reset index in a given DataFrame 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 How to get nth row in a Pandas DataFrame? Pandas Dataframes are basically table format data that comprises rows and columns. Now for accessing the rows from large datasets, we have different methods like iloc, loc and values in Pandas. The most commonly used method is iloc(). Let us consider a simple example.Method 1. Using iloc() to access 4 min read Insert row at given position in Pandas Dataframe Inserting a row in Pandas DataFrame is a very straight forward process and we have already discussed approaches in how insert rows at the start of the Dataframe. Now, let's discuss the ways in which we can insert a row at any position in the dataframe having integer based index.Solution #1 : There d 3 min read Pandas DataFrame.reset_index() In Pandas, reset_index() method is used to reset the index of a DataFrame. By default, it creates a new integer-based index starting from 0, making the DataFrame easier to work with in various scenarios, especially after performing operations like filtering, grouping or multi-level indexing. Example 3 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 How to Convert Index to Column in Pandas Dataframe? Pandas is a powerful tool which is used for data analysis and is built on top of the python library. The Pandas library enables users to create and manipulate dataframes (Tables of data) and time series effectively and efficiently. These dataframes can be used for training and testing machine learni 2 min read How to Get the Common Index of Two Pandas DataFrames When working with large datasets in Python Pandas, having multiple DataFrames with overlapping or related data is common. In many cases, we may want to identify the common indices between two DataFrames to perform further analysis, such as merging, filtering, or comparison.This article will guide us 5 min read Like