I have a data frame that looks like this -
License_type | User
A1 | U1
A2 | U1
A2 | U1
A2 | U1
A3 | U1
A4 | U1
A1 | U2
A2 | U2
A2 | U2
A2 | U2
A2 | U3
A4 | U3
I want to create a stacked histogram where for each User, the licenses types are stacked...
CodePudding user response:
You can use Pandas' crosstab
to create the counts, then plot.bar
:
pd.crosstab(df['User'], df['License_type']).plot.bar(stacked=True)
Output:
CodePudding user response: