title: Pandas groupby where one of the group values is in a range
body: <p>I want to find the sizes of the groups that have at least one row with <code>0.5 &lt; C &lt; 1.0</code>. Given a dataframe like this:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>A</th>
  <th>B</th>
  <th>C</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>2</td>
  <td>0.1</td>
  </tr>
  <tr>
  <td>1</td>
  <td>2</td>
  <td>0.9</td>
  </tr>
  <tr>
  <td>1</td>
  <td>2</td>
  <td>1.0</td>
  </tr>
  <tr>
  <td>2</td>
  <td>5</td>
  <td>0</td>
  </tr>
  <tr>
  <td>2</td>
  <td>5</td>
  <td>0.1</td>
  </tr>
  <tr>
  <td>2</td>
  <td>5</td>
  <td>0.2</td>
  </tr>
  <tr>
  <td>3</td>
  <td>4</td>
  <td>0.6</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I'd like to see something like the following returned:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>A</th>
  <th>B</th>
  <th>Size</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>2</td>
  <td>3</td>
  </tr>
  <tr>
  <td>3</td>
  <td>4</td>
  <td>1</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I've tried the following:</p>
  <pre><code>group = dataset.groupby(['A', 'B'])
  filtered = group.filter(lambda x: 0.5 &lt; x['C'] &lt; 1.0)
  filtered.size()
  </code></pre>
  <p>However, I get this error on the second line:</p>
  <blockquote>
  <p>ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().</p>
  </blockquote>
  <p>The <code>any()</code> function makes sense in this context as I want <em>any</em> value for <code>C</code> to be between 0.5 and 1.0 in order to count that group, but I don't know where to put the <code>any()</code> call. I tried calling it on the lambda. I tried after <code>filter()</code>. Nothing I try works...</p>