title: How to pass labels to concatenated data frame to specify which data came from which CSV file while reading multiple CSV files using Glob
body: <p>I have 27 CSV files which contain data about the various country GDPs. I am reading those CSV files using Glob and then concatenating them into a single data frame. Now the problem is I want to specify labels so that in concatenated data frame I can identify which dataset is for which state.</p>
  
  <p>I have already tried to pass the list of states as key parameter available for pd.concat() method which does the required labeling but in my case, it is not working.</p>
  
  <pre><code>path = 'C:\folder A' # use your path
  all_files = glob.glob(path + "/*.csv")
  
  df_from_each_file = (pd.read_csv(f, encoding = "ISO-8859-1", index_col=None, header=0, sep=",") for f in all_files)
  
  concatenated_df = pd.concat(df_from_each_file, ignore_index=True,keys=['Andhra_Pradesh','Arunachal_Pradesh','Assam','Bihar','Chhattisgarh','Goa','Gujarat','Haryana','Himachal_Pradesh','Jharkhand','Karnataka','Kerala','Madhya_Pradesh','Maharashtra','Manipur','Meghalaya','Mizoram','Nagaland','Odisha','Punjab','Rajasthan','Sikkim','Tamil_Nadu','Telangana','Tripura','Uttar_Pradesh','Uttarakhand'], sort=True)
  </code></pre>