Are Pandas dataframe column names case sensitive?


#1

Question

Are Pandas dataframe column names case sensitive?

Answer

Yes, column names for dataframes are case sensitive.

Dataframe column names are essentially string values, which are case sensitive in Python. Because of this, you will need to be careful whenever you utilize column names, such as when renaming a column, accessing columns or performing functions on them.

Example

# Given a dataframe with a column "name"
# this will incorrectly try to select it
# due to incorrect casing
print(df["Name"])

# The correct casing would be
print(df["name"])