I'm trying to translate this pandas statement:
df.groupby(['X', 'Y'])['Z'].mean()
to polars, but i'm stuck at this point:
df.group_by(['X', 'Y'], maintain_order=True).select(pl.col('Z').mean())
where i get this error:
AttributeError: 'GroupBy' object has no attribute 'select'
Any help would be very appreciated!
You were close
df.group_by(['X', 'Y'], maintain_order=True).agg(pl.col('Z').mean())