I would like to retrieve the name of my pandas. For instance:
A=pd.DataFrame()
print('the name of my pandas is ' + XXX)
What should be XXX to get
the name of my pandas is A
I would like to retrieve the name of my pandas. For instance:
A=pd.DataFrame()
print('the name of my pandas is ' + XXX)
What should be XXX to get
the name of my pandas is A
As others have mentioned, this is more of a Python question. But over time I've realized that the simplest way to keep track of names of dataframe (and variables in general) is to just store them in a dictionary.
dfs_stored = {}
# do some procedure
for varname in varname_list:
dfs_stored[varname] = pd.DataFrame(some_data)
dfs_stored['A'] # lookup by name
I think this question is more about python than pandas. You can see how to view all defined variables in python on Geeks for Geeks.
This snippet can help you
A=pd.DataFrame()
all_variables = dir()
for name in all_variables:
if type(eval(name)) == pd.core.frame.DataFrame:
print('the name of my pandas is ' + name)