I am new on python and i have a doubt. I have the following dataframe:
country | year | seller |
---|---|---|
USA | 2005 | Maria |
USA | 2005 | Maria |
USA | 2006 | Maria |
France | 2005 | Maria |
France | 2006 | Maria |
France | 2006 | Maria |
France | 2006 | Maria |
Russia | 2005 | Maria |
Russia | 2005 | Maria |
Russia | 2006 | Maria |
Russia | 2006 | Maria |
Russia | 2006 | Maria |
I would like to know how can i can get the following result:
country | 2005 | 2006 |
---|---|---|
France | 1 | 3 |
Russia | 2 | 3 |
USA | 2 | 1 |
I am using the following code but it is not working
df.groupby('country')['year'].value_counts()
Somo advice on how can i get this result?
Thank you and a nice weekend!