plot.hist creates a histogram from numeric pandas data, making the distribution of a measured value visible at a glance. section 11.10
Inspecting tip percentages
Filter out nonpositive fares, calculate tip_percentage, keep values at or below 0.5, and plot the resulting Series: df.loc[lambda df_: df_['fare_amount'] > 0].assign(tip_percentage=lambda df_: df_['tip_amount'] / df_['fare_amount']).loc[lambda df_: df_['tip_percentage'] <= 0.5, 'tip_percentage'].plot.hist(). section 11.10
(
df
.loc[lambda df_: df_['fare_amount'] > 0]
.assign(tip_percentage =
lambda df_: df_['tip_amount'] / df_['fare_amount'])
.loc[lambda df_: df_['tip_percentage'] <= 0.5,
'tip_percentage']
.plot.hist()
)
Open the complete method-chaining example for calculating and filtering tip percentages before calling plot.hist. section 11.10
