Use plot.bar to turn tabular or grouped pandas results into bars. A grouped result supplies the x-axis through its index, while its values determine bar heights. section 11.10
Compare monthly taxi revenue and rides
Group taxi records by pickup year and month, sum total_amount, and call .plot.bar(figsize=(10, 10)) to compare revenue. For ride counts, select passenger_count and use .count() before plotting. Extend the comparison with .plot.bar(stacked=True) after summing fare components such as fare_amount, tips, and tolls. section 11.10
(
df
.groupby([df['tpep_pickup_datetime'].dt.year,
df['tpep_pickup_datetime'].dt.month])
['total_amount'].sum()
.plot.bar(figsize=(10,10))
)
The executable pipeline shows grouping by datetime components, aggregating total_amount, and rendering the result as a sized bar plot. section 11.10
