Get the name of a pandas DataFrame

前端 未结 5 560
灰色年华
灰色年华 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 06:53

    Here is a sample function: 'df.name = file` : Sixth line in the code below

    def df_list(): filename_list = current_stage_files(PATH) df_list = [] for file in filename_list: df = pd.read_csv(PATH+file) df.name = file df_list.append(df) return df_list

提交回复
热议问题