title: How to sum based on the condition of two columns and presented in crosstab format using Pandas?
body: <p>Given the dataframe below:</p>
  <pre><code>Name    Activity    Hour    Month
  A       TT          5       1
  A       TT          2       1
  A       UU          1       1
  A       UU          1       2
  A       UU          1       3
  B       TT          40      3
  C       UU          10      1
  D       TT          2       2
  D       TT          2       2
  D       TT          2       2
  D       TT          5       1
  </code></pre>
  <p>The next step is to get the summation if the rows have identical value of the column <code>Name</code> and <code>Activity</code>.</p>
  <p>For example, for the case <code>Name: A</code> and <code>Activity: TT</code> will give the summation of <code>7</code></p>
  <p>Then, I would like to present it in a cross tab format which is group according to <code>month</code> and <code>activity</code>, as shown below</p>
  <pre><code>                Month
         1           2          3
      TT  UU      TT  UU      TT  UU
  A   7   1       0   1       0   1
  B   0   0       0   0       40  0
  C   0   10      0   0       0   0
  D   5   0       6   0       0   0
  </code></pre>
  <p>May I know whether this can achieve directly using pandas crosstab?</p>
  <p>p.s., similar but different topic has been discussed separately <a href="https://stackoverflow.com/q/64273360/6446053">here</a>. Please let me know if this thread is considered to be a duplicate of the OP</p>