Is there a way to both bin and aggregate (with some other function than count) in seaborn.objects? I'd like to compute the mean per bin and right now I'm using the following:
import seaborn.objects as so
import pandas as pd
import seaborn as sns
df = sns.load_dataset("penguins")
df2 = (
df.groupby(pd.cut(df["bill_length_mm"], bins=30))[["bill_depth_mm"]]
.mean()
)
df2["bill_length_mm"] = [x.mid for x in df2.index]
p = so.Plot(df2, x="bill_length_mm", y="bill_depth_mm").add(so.Bars())
p
