0

I have a Dataframe similar to this one:

Hour    Place
01:00      C
02:00      B
03:00      B
04:00      A
03:00      B

I want to groupby Place and have additional rows, in which the total occurings of an Hour are listed like so:

        00:00  01:00  02:00  03:00  04:00  ... 23:00
A         0      0      0      0      1         0
B         0      0      1      2      0         0
C         0      1      0      0      0         0

Something i know that would work is removing all Places but A from the df, groupby() Hour and count() the Place instead and transpose the table. Then doing the same for B, C... and putting them all together again in the end. Is there a more efficient to achieve the table above?

Karandash_
  • 65
  • 6

0 Answers0