title: Compute number of missing values by group on another dataframe column based on conditions
body: <p>Let's say I have the following data:</p>
  <pre><code>df=pd.DataFrame({&quot;id&quot;:[1,1,1,2,2,3,4],
               &quot;date&quot;:[2019,2019,2020,2020,2020,2020,2021],
               &quot;subgroup&quot;:[&quot;con&quot;,&quot;ind&quot;,&quot;ind&quot;,&quot;con&quot;,&quot;ind&quot;,&quot;ind&quot;,&quot;ind&quot;],
               &quot;value&quot;:[1,None,2,None,1,3,4]})
  </code></pre>
  <p>I want to group by ID and DATE and, among those duplicates, get a column which counts the number of missing values in the Value column based on the value in the Subgroup column (in this case when Subgroup==&quot;Ind&quot;)
  The output would look like this:</p>
  <pre><code>id      date    subgroup   value  count
  1       2019      con      1       1
  1       2019      ind      None    1
  1       2020      ind      2       0
  2       2020      con      None    0
  2       2020      ind      1       0
  3       2020      ind      3       0
  4       2021      ind      4       0
  </code></pre>
  <p>How can I achieve this?</p>