How do I get the name of a DataFrame and print it as a string?
Example:
boston (var name assigned to a csv file)
boston
import pandas as pd boston = pd.read_csv('boston.csv') print('The winner is team A based on the %s table.) % boston
You can name the dataframe with the following, and then call the name wherever you like:
import pandas as pd df = pd.DataFrame( data=np.ones([4,4]) ) df.name = 'Ones' print df.name >>> Ones
Hope that helps.
1.4m articles
1.4m replys
5 comments
56.9k users