How to read only header of CSV file in Python using Pandas

You can read only header of CSV file in Python using Pandas with the following code. I highly recommend you This book to learn Python.

Read Header of CSV File

# Import the Pandas library as pd
import pandas as pd

# Read the CSV file
df = pd.read_csv("house_price.csv")

# Display the Header of CSV
print(df.columns)

Output:

Index(['Area', 'Rooms', 'House_Age', 'Price'], dtype='object')

Free Learning Resources

Leave a Comment

Your email address will not be published.