I have a dataset which looks as follows:
Station | Month | Year |
---|---|---|
A | Jan | 2021 |
A | Feb | 2021 |
A | Jan | 2021 |
B | Mar | 2021 |
B | Mar | 2021 |
C | Apr | 2021 |
D | Feb | 2021 |
I am looking to write some code which can identify each unique value within a row and tell me how often it occurs. eg. For the month column the code should tell be Jan occurs twice, Feb occurs twice, Mar occurs twice and Apr occurs once. It would output similar for the Station and Year columns.
My code looks like this at present, but is not working as intended:
import pandas as pd
for col in df["Month"]: print((df["Month"])[col].unique())