FAQ: Aggregates in Pandas - Calculating Aggregate Functions III

I had problem getting the lambda function to work. Single quotes (')around shoe_color was causing an error. When I changed them to double quotes("), it worked. Not sure what the difference is.

Didn’t work: cheap_shoes = orders.groupby[‘shoe_color’].price.apply(lambda x: np.percentile(x, 25)).reset_index()

Worked: cheap_shoes = orders.groupby[“shoe_color”].price.apply(lambda x: np.percentile(x, 25)).reset_index()