title: Access values in a dictionary of dataframes and create a new dataframe with certain columns in pandas
body: <p>Python beginner here.</p>
  
  <p>I have a dictionary of dataframes as:
  <a href="https://i.stack.imgur.com/W7BOY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W7BOY.png" alt="enter image description here"></a></p>
  
  <p>each dataframe corresponds to a different day:</p>
  
  <p><a href="https://i.stack.imgur.com/LGRFY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LGRFY.png" alt="enter image description here"></a>
  Each day contains 8 columns with data, I am interested in -> ['WINDSPEED_wspd1[m/s]']</p>
  
  <p>I want to create a new variable (dataframe) that contains only the data regarding windspeed with one column for each day (each key in the dictionary of dataframes)</p>
  
  <p>I created a function to do this</p>
  
  <pre><code>def get_variables(DictOfDataFrames, ColumnsToPlot, filenames):
       for key, df in DictOfDataFrames.items():  # Use magic unpacking to avoid multiple meteo_data[key]-call
      x=pd.DataFrame(index=range(0,86400,1),columns=filenames)
  
           if key in filenames:
  
               x[key]=df[ColumnsToPlot[0]][0:86400].copy()
               y=pd.DataFrame(DictOfDataFrames[key][ColumnsToPlot[1][0:86399]])
  return xy
  WindSpeed, WindDirection = get_variables(DATA_Meteo,['WINDSPEED_wspd1[m/s]','WINDDIR_wdir1[deg]'], filenames_Meteo[1:3])
  </code></pre>
  
  <p>However, in this way I overwrite y in every iteration, so it returns the values of the last filename it went in the loop. On the other hand, x is returned as full of NaN.</p>
  
  <p>I tried with insert, append, I am going crazy with this which should be super simple to code.</p>