Pandas How To Uncategorized How to make first row as header in Pandas

How to make first row as header in Pandas

From this article you will learn How to make first row as header in Pandas.

Making first row as a header

You can make the first row as header in Pandas by setting the header parameter in the read_csv() method to 0:


df = pd.read_csv("file.csv", header=0)

Or, if you’ve already loaded the data into a DataFrame, you can set the column names using the .columns attribute:

df.columns = df.iloc[0]


df = df.iloc[1:]

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post