title: Dynamically naming DataFrames in Pandas
body: <p>Imagine I have 2 data frames as such:</p>
  
  <pre><code>foo = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]})
  bar = pd.DataFrame({'c':[7,8,9], 'd':[10,11,12]})
  </code></pre>
  
  <p>I want to subset each of these data frames and put them in a new data frame with a dynamic name. When I look up anything on dynamic naming in python, they say, don't do it, use a <a href="https://www.google.com/#q=dynamic+naming+python" rel="nofollow">dictionary</a>. 
  I can't quite figure out how to make it work though. Essentially I want the following:</p>
  
  <pre><code>foo_first = foo[0:1]
  bar_first = bar[0:1]
  </code></pre>
  
  <p>But I want to be able to do it looping through a list. I would imagine it something like this, if I'm trying to do it with a dictionary:</p>
  
  <pre><code>dfs_list = [foo, bar]
  dfs_dict = {}
  
  for x in dfs_list:
      dfs_dict[x+'_first']=foo[0:1]
  </code></pre>
  
  <p>Which does not work. </p>
  
  <p>You might be wondering what I'm actually trying to do, as my example is so arbitrary and pointless. In my real world example, I have several data frames indexed by date. I want to create new dataframes based on the names of these old dataframes for the current year and month. So if foo and bar were giant datasets with date indexes, I want to automate:</p>
  
  <pre><code>foo_year = foo['2015-01-01':'2015-12-31']
  bar_year = bar['2015-01-01':'2015-12-31']
  foo_month = foo['2015-08-01':'2015-08-31']
  bar_month = foo['2015-08-01':'2015-08-31']
  </code></pre>
  
  <p>Any help?</p>