How to use drop() function In Python Pandas
Here we are using the drop() function to remove first row using the index parameter set to 0
Syntax:
data.drop(index=0)
where data is the input dataframe
Example: Drop the first row
Python3
# import pandas module import pandas as pd # create student dataframe with 3 columns # and 4 rows data = pd.DataFrame({ 'id' : [ 1 , 2 , 3 , 4 ], 'name' : [ 'sai' , 'navya' , 'reema' , 'thanuja' ], 'age' : [ 21 , 22 , 21 , 22 ]}) # drop first row data.drop(index = 0 ) |
Output:
How to Drop First Row in Pandas?
In this article, we will discuss how to drop the first row in Pandas Dataframe using Python.
Dataset in use:
Contact Us