Using this function and call:
def top(df, n=3, column='tip_pct'):
return df.sort_values(by=column, ascending=False)[:n]
tips.groupby('smoker').apply(top)
I was able to obtain this output:
Is there a way to show the same output using a lambda function?

Since the function is a one-liner, you can just copy the
returnexpression into the body of the lambda.