Pandas Filtering By Date And OR Condition
<p>I'm using <code>pandas</code> to try and get a count for the members that have purchased a specific type of contract between two dates. The dataframe that I'm working with resembles: </p>

<pre><code>Member Nbr       Contract-Type    Date-Joined 
20           1 Year Membership     2011-08-01   
3128        3 Month Membership     2011-07-22   
3535        4 Month Membership     2015-02-18  
3760        4 Month Membership     2010-02-28
3762        3 Month Membership     2010-01-31
3882        1 Month Membership     2010-04-24    
3892        3 Month Membership     2010-03-24     
4116        3 Month Membership     2014-12-02   
4700        1 Month Membership     2014-11-11   
4802        4 Month Membership     2014-07-26   
5004         1 Year Membership     2012-03-12
5020         1 Year Membership     2010-07-28    
5022        3 Month Membership     2010-06-25    
5130         1 Year Membership     2011-01-04
                      ...
</code></pre>

<p>I am able to get the count if there is only one contract type that I'm interested in using </p>

<pre><code>print(len(df[(df['Date-Joined'] &gt; '2010-01-01') 
          &amp; (df['Date-Joined'] &lt; '2012-02-01')
          &amp; (df['Member Type'] == '1 Year Membership')]))
</code></pre>

<p>When I try something similar by specifying a <code>1 Year Membership</code> or <code>4 Month Membership</code> with the following code</p>

<pre><code>print(len(df[(df['Date-Joined'] &gt; '2013-01-01') 
      &amp; (df['Date-Joined'] &lt; '2013-02-01')
      &amp; (df['Member Type'] == '1 Year Membership')
      or (df['Member Type'] == '4 Month Membership')]))
</code></pre>

<p>I get the following error</p>

<pre><code>ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
</code></pre>

<p>and replacing the <code>or</code> condition by an <code>&amp;</code> condition returns <code>0</code></p>