title: Pandas Filter CSV by Date
body: <p>Pandas Filter by Date
  How can I filter a CSV with Dates</p>
  
  <p>Example CSV</p>
  
  <pre><code>User    Dates       Hours   shift
  User1   01.01.2012      5   aaa 
  User1   02.01.2012      5   aaa
  User1   03.01.2012      2   bbb
  User1   04.01.2012      3   aaa
  .....
  User1   12.03.2012      1   aaa
  User1   13.03.2012      8   ccc
  .....
  User2   04.02.2012      4   aaa
  User2   05.02.2012      3   bbb
  </code></pre>
  
  <p>end so on</p>
  
  <p>I can filter by a User with</p>
  
  <pre><code>use = users.loc["User1"]
  </code></pre>
  
  <p>also I can sum all Hours</p>
  
  <pre><code>print(use["Hours"].sum()
  </code></pre>
  
  <p>and I can count his shifts</p>
  
  <pre><code>counts = use.loc[ou['Shift'] == 'aaa', 'Hours'].value_counts()
  </code></pre>
  
  <p>But I dont know how I can filter by the Date and and the Statements above.
  Like count all shifts in March by User2 or Sum all Hours done in Feb by User1</p>
  
  <p>More or less I manged to Filter the Table by Date and User with</p>
  
  <pre><code>use['Date'] = pd.to_datetime(use['Date'], infer_datetime_format=True, exact=True)
  mask = (use['Datum'] &gt; Start) &amp; (use['Date'] &lt;= End)
  print(use.loc[mask])
  </code></pre>
  
  <p>But I cant figure out how to combine them.
  Desired Output</p>
  
  <pre><code>Overview March 2016
  User1 made 3 aaa shifts
  User1 worked 12h in March 2016
  </code></pre>
  
  <p>update:
  I made some progress</p>
  
  <pre><code>print(use[use['Date'] &gt; '02.01.2012'],['hours'].sum()))
  </code></pre>
  
  <p>works fine but not exctly what I want. With:</p>
  
  <pre><code>print(use[use['Date'] &gt; '02.01.2012'] &amp; (use[use['Date'] &lt; '02.05.2012'],['hours'].sum()))
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>AttributeError: 'list' object has no attribute 'sum'
  </code></pre>