Finding header of CSV file with pandas

Viewed 55

Is there any easy way to store the values of a CSV file's header? I've been researching but I can't find any info about it.

1 Answers

this should work

df = pd.read_csv(path to file)
df.columns = list(df)  # to put header inside data frame 
print(df)
var = list(df.columns) # to read header from data frame
Related