I have multiple dataframes:
df1, df2, df3,..., dfn
They have the same type of data but from different groups of descriptors that cannot be joined. Now I need to apply the same function to each dataframe manually.
How can I apply the same function to multiple dataframes?
pipe
+ comprehensionIf your dataframes contain related data, as in this case, you should store them in a
list
(if numeric ordering is sufficient) ordict
(if you need to provide custom labels to each dataframe). Then you canpipe
each dataframe through a functionfoo
via a comprehension.List example
Then access your dataframes via
df_list[0]
,df_list[1]
, etc.Dictionary example
Then access your dataframes via
df_dict['first]
,df_dict['second']
, etc.If the data frames have the same columns you could
concat
them to a single data frame, but otherwise there is not really a "smart" way of doing it: