I have a dataframe like this:
import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline df = pd.DataFrame({\'category\': lis
You can also use this
pd.pivot_table(df, values = 'B', index = 'category', columns = 'sex', aggfunc = lambda x: len(x)).plot.bar()
which results in exactly the same plot.