I have the following dataframe:
I want to rename the columns to snake case using a function I defined:
def to_snakecase(cols):
map_dict = {}
for col in cols:
map_dict[col] = col.lower().strip().replace(' ', '_')
When I write the code:
covid_df.rename(to_snakecase(covid_df.columns), axis=1, inplace=True)
I get the error: must pass an index to rename
I have looked at the documentation but haven't figured it out. Please help. Thank you.