I have a list of dataframes that I want to loop through all of them and perform the same actions. The dataframes have the same format. I used a function and a loop like you see in the code below but it seems that the only changes that are passed is the renaming of the columns. Am I missing something here?
def changes(df):
df = df[["A","B","C"]]
df = df/1000000
df["A"] = df["A"]*1000000
df.rename(columns={'A': 'A1', 'B': 'B1','C': 'C1'}, inplace=True)
df["A"] = df["A"].astype(int)
df = df.transpose()
return df
dfs = [df1,df2,df3]
for i in dfs:
i = changes(i)