pandas apply processes rows individually with a callable, much like map. Setting axis=1 supplies each DataFrame row to the callable and returns a Series of results. section 7.2.2
Computing mean tip fraction
A row-wise lambda can divide tip_amount by total_amount, then mean() can aggregate the resulting fractions. This apply version took about 9.5 seconds, versus 18 seconds for itertuples; vectorization reduced the same computation to about 32 milliseconds. section 7.2.2


