I would like to concat multiple dataframes into a single dataframe using the names of the dataframes as strings from a list. This is similar to:
df1 = pd.DataFrame({'x': [1, 2, 3], 'y': ['a', 'b', 'c']}) df2 = pd.DataFrame({'x': [4, 5, 6], 'y': ['d', 'e', 'f']}) pd.concat([df1, df2]) but instead I want to provide a list of dataframe names as strings
For example,
pd.concat(['df1', 'df2']) Is this possible?
globalsnamespace. So you can get them usingglobals()[name].pd.concat([globals()[x] for x in ['df1', 'df2']])but this is not idiomatic and you should store your dataframes in a local dictionary and reference from that.