librasteve / raku-Dan-Polars

Raku Polars binding
Artistic License 2.0
5 stars 2 forks source link

Add DF level Polars sort in a query API stylee #16

Closed librasteve closed 1 year ago

librasteve commented 1 year ago

658 #`[ dataframe level sort not yet implemented 659 method orderby( @colnames ) { # takes Array of colnames (unlike Polars native call) 660 $!rc .= sort( $_ ) for @colnames; 661 self 662 }
663 #]

def get_person() -> pl.Expr: return pl.col("first_name") + pl.lit(" ") + pl.col("last_name")

q = ( dataset.lazy() .sort("birthday", descending=True) .group_by("state") .agg( get_person().first().alias("youngest"), get_person().last().alias("oldest"), ) .limit(5) )

df = q.collect() print(df)

librasteve commented 1 year ago

need to consider trade off between performance and API complexity / overlap with pure Dan

librasteve commented 1 year ago

this has morphed into "implement explicit queries" and ... this is beyond the current scope of Dan::Polars