Week12- Stacked Bar plot: TypeError: only size-1 arrays can be converted to Python scalars

I was trying to plot stacked bar plot is similar manner shown in course. Plot total and maharashtra as stacked plot. Below is the code and it is throwing an error. could you please help.

1 Like

If you look at the y-values in plot, they are not in order. Most likely their type is not number. You can confirm the type by printing subData.dtypes?

If not numeric, you can convert ‘subData’ to numeric and then plot again.

subData = subData.apply(pd.to_numeric)
1 Like

It worked. Thanks for the reply.

1 Like