A bar chart turns grouped categorical values into rectangular bars, making differences easier to see than a page of numerical output. In pandas, prepare the grouping, select the measure, sort when needed, and call plot.bar(). section 11.1 section 11.2
A practical bar-chart workflow is:
- Group rows by the category or categories that should label the x-axis. section 11.10
- Select one numeric Series or aggregate a selected set of columns. section 11.2 section 11.10
- Sort the resulting Series before plotting when the question requires an ordered comparison. section 11.2
- Use figsize when many categories make the default figure difficult to read. section 11.2
- Use stacked=True to show how several numeric components combine within each category. section 11.9 section 11.10
Taxi payments by month and year
After concatenating four taxi data frames, group by pickup year and month, sum total_amount, and plot the resulting indexed Series. The index supplies the x-axis and the values supply the bar heights. Repeat the pattern with passenger_count.count() to chart ride counts. section 11.10 section 11.9
City comparisons
For the 1,000 largest U.S. cities, count city rows by state, sort the counts, and plot them. For Pennsylvania, filter rows, clean percentage strings, convert them to numbers, sort, and plot city growth. section 11.2
(
df
.groupby([df['tpep_pickup_datetime'].dt.year,
df['tpep_pickup_datetime'].dt.month])
['total_amount'].sum()
.plot.bar(figsize=(10,10))
)
This compact chain shows the full pattern: group taxi records, aggregate total payments, and render a bar chart with a larger figure. section 11.10








