title: How to keep Zero counts for pandas groupby count for 2 columns dataframe?
body: <p>If the data frame has 3 columns, I found this StackOverflow answer that gives zero counts:
  <a href="https://stackoverflow.com/questions/37003100/pandas-groupby-for-zero-values">Pandas groupby for zero values</a></p>
  
  <p>But, HOW to do this for the data frame having only two columns:</p>
  
  <p><strong>Question</strong><br>
  <strong>NOTE: Answer preferable in Chain operations</strong>:</p>
  
  <pre class="lang-py prettyprint-override"><code>import numpy as np
  import pandas as pd
  
  df = pd.DataFrame({'date': pd.date_range('2018-01-01', periods=6),
                     'a': range(6),
                     })
  
  df.iloc[2,0] = df.iloc[1,0]
  print(df)
          date  a
  0 2018-01-01  0
  1 2018-01-02  1
  2 2018-01-02  2
  3 2018-01-04  3
  4 2018-01-05  4
  5 2018-01-06  5
  </code></pre>
  
  <p>To geth the counts of a I do this:</p>
  
  <pre class="lang-py prettyprint-override"><code>df1 = (df.query("a &gt; 0")
      .groupby(['date'])[['a']]
      .count()
      .add_suffix('_count')
      .reset_index() 
       )
  
  print(df1)
          date  a_count
  0 2018-01-02        2
  1 2018-01-04        1
  2 2018-01-05        1
  3 2018-01-06        1
  </code></pre>
  
  <p><strong>Required Answer from Chain operation</strong></p>
  
  <pre><code>        date  a_count
  0 2018-01-01        0  # also include this row
  0 2018-01-02        2
  1 2018-01-04        1
  2 2018-01-05        1
  3 2018-01-06        1
  </code></pre>
  
  <p>My attempt:</p>
  
  <pre class="lang-py prettyprint-override"><code>df1 = (df.query("a &gt; 0")
      .groupby(['date'])[['a']]
      .count()
      .add_suffix('_count')
      .unstack(fill_value=0)
      .to_frame()
      .stack()
      .reset_index() 
       )
  
  print(df1)
     level_0       date  level_2  0
  0  a_count 2018-01-02        0  2
  1  a_count 2018-01-04        0  1
  2  a_count 2018-01-05        0  1
  3  a_count 2018-01-06        0  1
  </code></pre>
  
  <p>This does not work.</p>
  
  <p>How to fix this ?</p>
  
  <p>Related links:<br>
  <a href="https://stackoverflow.com/questions/37003100/pandas-groupby-for-zero-values">Pandas groupby for zero values</a>  </p>