code in user guider is as follows:
def get_person() -> pl.Expr:
return pl.col("first_name") + pl.lit(" ") + pl.col("last_name")
q = (
dataset.lazy()
.sort("birthday")
.groupby(["state"])
.agg(
[
get_person().first().alias("youngest"),
get_person().last().alias("oldest"),
]
)
.limit(5)
)
df = q.collect()
df
1 May the real order of sort().groupby()
execute groupby
first and then execute sort
? ,which is similar to pandas
?
answer by @tvashtar about this question provides some tips.