I'm looking for a function along the lines of
df.groupby('column').agg(sample(10))so that I can take ten or so randomly-selected elements from each group.
This is specifically so I can read in a LazyFrame and work with a small sample of each group as opposed to the entire dataframe.
Update:
One approximate solution is:
df = lf.groupby('column').agg( pl.all().sample(.001) )df = df.explode(df.columns[1:])Update 2
That approximate solution is just the same as sampling the whole dataframe and doing a groupby after. No good.