Pandas - applying groupings and counts to multiple columns in order to generate/change a dataframe
<p>I'm sure what I'm trying to do is fairly simple for those with better knowledge of PD, but I'm simply stuck at transforming:</p>

<pre><code>+---------+------------+-------+
| Trigger |    Date    | Value |
+---------+------------+-------+
|    1    | 01/01/2016 |   a   |
+---------+------------+-------+
|    2    | 01/01/2016 |   b   |
+---------+------------+-------+
|    3    | 01/01/2016 |   c   |
+---------+------------+-------+

...etc, into:

+------------+---------------------+---------+---------+---------+
|   Date     |  #of triggers       | count a | count b | count c |
+------------+---------------------+---------+---------+---------+
| 01/01/2016 | 3                   |    1    |    1    |     1   |
+------------+---------------------+---------+---------+---------+
| 02/01/2016 | 5                   |    2    |    1    |     2   |
+------------+---------------------+---------+---------+---------+

... and so on
</code></pre>

<p>The issue is, I've got no bloody idea of how to achieve this..
I've scoured SO, but I can't seem to find anything that applies to my specific case.</p>

<p>I presume I'd have to group it all by date, but then once that is done, what do I need to do to get the remaining columns?</p>

<p>The initial DF is loaded from an SQL Alchemy query object, and then I want to manipulate it to get the result I described above. How would one do this?</p>

<p>Thanks</p>

<pre><code>df.groupby(['Date','Value']).count().unstack(level=-1)
</code></pre>

python pandas dataframe