Help with pie chart - How do you aggregate your pie slices to create fewer?


I need help with a pie chart - I am looking to aggregate the smaller categories to create an “Other” category to keep the number of wedges under 4. I am certain I have learned this on Code Academy but I’ve forgotten how to do it and I’m unable to find this information anywhere now.

Any help is appreciated, I’ve been searching for over an hour with no luck.

You could use Matplotlib. Do you have any code so far that you’d like to share?

I want to create a pie chart with all the job opportunities with an ASAP start date in one wedge, and every other date grouped under an ‘Other’ wedge. I thought we could use value_counts with a constraint to create the ‘Other’ category, but if it’s possible I can’t figure it out.

Right now this is what I have.


ASAP 6856
01 September 2012 31
March 2006 27
November 2006 22
January 2010 19
Name: StartDate, Length: 1140, dtype: int64

df_clean['Category'] = np.where(df_clean['StartDate'] == "ASAP", 'ASAP', 'Other')

plt.pie(df_clean['Category'].value_counts().values, labels=df_clean['Category'].value_counts().index);

what happens with that code? Is there an error message?

You can use plot() and the parameter kind='pie'


In that example, “s” is the series, or the categorical values in a column.


I hope that helps.