I have 10 dataframes that have the same structure (same number of rows and columns) and I am trying to find an efficient way of performing several actions such as renaming columns with a for loop. I have tried putting them in a list such as
dfs = [df1, df2, df3]
for i in dfs:
i.rename(columns={'A': 'a1'},inplace=True)
but it doesn't work. Another issue occurs if I try to use a function and then loop such as:
def groupdfs(anydf)
anydf = anydf.groupby("A").sum
for i in dfs:
groupdfs(i)
No changes are happening to the dataframes. I have searched similar old questions but nothing have worked. What is the best way to loop through many dataframes when you want to perform the same changes to each of them?