Get the name of a pandas DataFrame

前端 未结 5 554
灰色年华
灰色年华 2020-11-27 06:48

How do I get the name of a DataFrame and print it as a string?

Example:

boston (var name assigned to a csv file)

import pandas         


        
5条回答
  •  一生所求
    2020-11-27 07:08

    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.

提交回复
热议问题