0

I would like to plot a pie chart from my pandas data Frame of customer buying behaviours

PREMIUM_CUSTOMER TOT_SALES
Mainstream 750744.50
Budget 676211.55
Premium 507458.95

This is my code so far

plt.style.use("fivethirtyeight")
labels = ['Mainstream','Budget','Premium']
df_customer.plt.pie("PREMIUM_CUSTOMER","TOT_SALES",labels=labels,wedgeprops={'edgecolor':'black'}, shadow = True,startangle =90, autopct='%1.11f%%')
plt.title("Percentage of sales to customer types ")
plt.tight_layout()
plt.show()
JohanC
  • 71,591
  • 8
  • 33
  • 66
coja56
  • 25
  • 5
  • Try this one: https://stackoverflow.com/questions/38337918/plot-pie-chart-and-table-of-pandas-dataframe – Lasith Niroshan Jan 12 '23 at 22:33
  • Maybe add an `'o'` in `df_customer.plot.pie`? Maybe you want to remove `labels=` as they come from a dataframe column? What is the exact problem you are facing? – JohanC Jan 12 '23 at 22:43
  • @JohnanC the pie chart is not showing – coja56 Jan 12 '23 at 23:01
  • 1
    What error or warning do you get? Did you try `df_customer.set_index("PREMIUM_CUSTOMER")["TOT_SALES"].plot.pie(autopct='%1.1f%%')`? – JohanC Jan 12 '23 at 23:48

0 Answers0