title: Appending dataframes from json files in a for loop
body: <p>I am trying to iterate through json files in a folder and append them all into one pandas dataframe. </p>
  
  <p>If I say</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  import json
  from pandas.io.json import json_normalize
  import os
  
  
  directory_in_str = 'building_data'
  directory = os.fsencode(directory_in_str)
  
  df_all = pd.DataFrame()
  with open("building_data/rooms.json") as file:
    data = json.load(file)
  df = json_normalize(data['rooms'])
  df_y.append(df, ignore_index=True)
  </code></pre>
  
  <p>I get a dataframe with the data from the one file. If I turn this thinking into a for loop, I have tried</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  import json
  from pandas.io.json import json_normalize
  import os
  
  directory_in_str = 'building_data'
  directory = os.fsencode(directory_in_str)
  
  df_all = pd.DataFrame()
  for file in os.listdir(directory):
      with open(directory_in_str+'/'+filename) as file:
          data = json.load(file)
      df = json_normalize(data['rooms'])
      df_all.append(df, ignore_index=True)
  
  print(df_all)
  </code></pre>
  
  <p>This returns an empty dataframe. Does anyone know why this is happening? If I print <code>df</code> before appending it, it prints the correct values, so I am not sure why it is not appending.</p>
  
  <p>Thank you!</p>