I have to apply many functions to certain columns in my df. But there are many columns. Is there any way to give these groups of columns a certain name and then apply functions to them?
I am looking for something like
df[['One', 'Two',...'Sixty']] = values
values.apply(lambda x: x.astype(str).str.lower())
>Solution :
Probably you could first create a list of column names and then use pd.DataFrame.isin as follows:
values = ['One', 'Two',...'Sixty']
df.loc[:, df.columns.isin(values)].apply(lambda x: x.astype(str).str.lower())