0

Simple question but I have data that looks like:

Date           Facility              value
jan-1          Ogden                 1
jan-1          North Haverbrook      2
jan-1          Sinn                  3
jan-1          Lister                2
jan-2          Ogden                 1
jan-2          Corodo                5
jan-2          North Haverbrook      4
jan-3          Ogden                 1
jan-3          Lister                2

I need a way to count the values where I get an output that looks like:

Facility              value      count
Ogden                 1          3
North Haverbrook      2          1
Sinn                  3          1
Lister                2          2
Corodo                5          1
North Haverbrook      4          1

I've been able to count on values alone with df['value'].value_counts() but I'd like to somehow groupby the Facility as well.

Is there any easy way to go about this?

HelloToEarth
  • 2,027
  • 3
  • 22
  • 48

0 Answers0