A pie chart treats a total like a whole pie: each category becomes a sector, and its angular size shows that category’s share of the total. Use it when comparing parts of one meaningful whole, rather than unrelated measurements. section 11.2
A practical pandas workflow is:
- Filter the rows representing the population of interest. section 11.2
- Select the category and numeric value columns. section 11.2
- Set the category as the index and retrieve the numeric column as a Series. section 11.2
- Call `.plot.pie()` and adjust the figure size when many sectors need room. section 11.2
Comparing Massachusetts city populations
After selecting Massachusetts rows, keep `city` and `population`, make `city` the index, and plot the resulting population Series: `df.loc[df['state'] == 'Massachusetts', ['city', 'population']].set_index('city')['population'].plot.pie(figsize=(10, 10))`. The chart shows Boston dominating the urban population represented in the dataset, followed by Worcester and Springfield. section 11.2 section 11.1
Institution types offering computer science
Group undergraduate computer-science institutions by `CONTROL`, count them, and plot the counts: `fields_of_study_df.loc[(fields_of_study_df['CIPDESC'].str.contains('Computer Science')) & (fields_of_study_df['CREDDESC'] == 'Bachelors Degree'), ['CONTROL', 'INSTNM']].groupby('CONTROL').count()['INSTNM'].plot.pie()`. This turns a summary table into a direct comparison of institutional shares. section 13.3
Interpret sectors as proportions of the supplied total, not as the entire real-world population unless the data represents that whole. Extend the exercise by changing the filter, grouping categories differently, or comparing the result with a bar chart. section 11.1 section 13.3


