3

Given the following dataframe

data = {
    'Code': ['A', 'C', 'B', 'B', 'C', 'B', 'A', 'C', 'C', 'B'],
    'Month': [4, 2, 4, 1, 3, 2, 3, 1, 4, 3],
    'Col A': [3, 0, 51, 0, 0, 7, 5, 0, 0, 12],
    'Col B': [66, 5, 125, 5, 41, 52, 22, 14, 51, 122]
}

df = DataFrame(data)
d = df.groupby(['Month','Code']).sum()

Dataframe

How can I create a bar plot like this?: Desired plot

Adcade
  • 151
  • 7
  • Do you have tried this solution: https://stackoverflow.com/questions/19184484/how-to-add-group-labels-for-bar-charts-in-matplotlib?answertab=active#tab-top – BenHeid May 23 '21 at 08:19
  • Thank you! https://stackoverflow.com/a/39502106/13075718 is exactly what I needed (I may do a few tweaks for aesthetics, but the logic is right) – Adcade May 24 '21 at 16:00

0 Answers0