pipe
+ comprehension
If your dataframes contain related data, as in this case, you should store them in a list
(if numeric ordering is sufficient) or dict
(if you need to provide custom labels to each dataframe). Then you can pipe
each dataframe through a function foo
via a comprehension.
List example
df_list = [df1, df2, df3]
df_list = [df.pipe(foo) for df in df_list]
Then access your dataframes via df_list[0]
, df_list[1]
, etc.
Dictionary example
df_dict = {'first': df1, 'second': df2, 'third': df3}
df_dict = {k: v.pipe(foo) for k, v in df_dict.items()}
Then access your dataframes via df_dict['first]
, df_dict['second']
, etc.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…