I have the following dataframe:
df = pd.DataFrame([{'animal': 'dog', 'years':10},
{'animal': 'dog', 'years':5},
{'animal': 'cat', 'years':3},
{'animal': 'cat', 'years':7}])
giving me:
animal years
0 dog 10
1 dog 5
2 cat 3
3 cat 7
Given the number of cats and dogs is always the same, how can I can turn it into:
dog cat
years 10 3
5 7
My ultimate goal is to make a boxplot showing years distrubution across each animal type.