I have a dataset that looks like this (assume this has 4 categories in Clicked
, the head(10)
only showed 2 categories):
Rank Clicked
0 2.0 Cat4
1 2.0 Cat4
2 2.0 Cat4
3 1.0 Cat1
4 1.0 Cat4
5 2.0 Cat4
6 2.0 Cat4
7 3.0 Cat4
8 5.0 Cat4
9 5.0 Cat4
This is a code that returns this plot:
eee = (df.groupby(['Rank','Clicked'])['Clicked'].count()/df.groupby(['Rank'])['Clicked'].count())
eee.unstack().plot.bar(stacked=True)
plt.legend(['Cat1','Cat2','Cat3','Cat4'])
plt.xlabel('Rank')
Is there a way to achieve this with seaborn (or matplotlib) instead of the pandas plotting capabilities? I tried a few ways, both of running the seaborn code and of preprocessing the dataset so it's on the correct format, with no luck.