Should dataframe column names always be capitalized?


#1

Question

In Pandas, should dataframe column names always be capitalized?

Answer

The short answer is, no. Column names in Pandas dataframes do not always have to be capitalized, and there is no strict requirement on how to case your column names.

However, there are a few important points you might keep in mind when you are naming columns for Pandas dataframes.

  • One point which also applies to Python in general, is that column name casing should usually be consistent. If you decide to capitalize one column name, then it might be good to capitalize all column names to stay consistent. This applies when naming variables, functions and almost anything else in Python.

  • One additional point is that when naming the columns, consider using “snake_case”, which uses casing in the form that this convention implies. This is because, it will give you the freedom to select columns of a dataframe using either format:
    df.column_name or df['column_name']