'DataFrame' object has no attribute 'column'

Question:

I’m trying to retrieve the column names of a dataframe, all in lower case, but that’s giving me the following Attribute Error: ‘DataFrame’ object has no attribute ‘column’.

import pandas as pd

df = pd.read_csv('C:/dataset.csv')

col_names=df.column.values.lower()
print(col_names)  

Why is this error showing up & how do I fix it?

Asked By: Apoorva

||

Answers:

IIUC, replace "column" by "columns" and use the str.lower accessor:

col_names = df.columns.str.lower().tolist()
Answered By: mozway
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.