Is it possible to do something like the following in python polars:
import polars as pl
import statsmodels.api as sm
lowess = sm.nonparametric.lowess
df = pl.DataFrame([pl.Series('x', ['a', 'a', 'a', 'b','b', 'b']),
pl.Series('y', [1, 2, 3, 1, 2, 3]),
pl.Series('z', [.2, .3, .5, .1, .3, .7])]
)
df.with_columns(
pl.struct('z', 'y').map_batches(lambda cols: pl.DataFrame(lowess(cols['z'], cols['y'], frac = .1)))
.over('x')
)
# ComputeError: TypeError: cannot select elements using Sequence with elements of type 'str'
I want to group by one or more columns and then apply a function with more than 1 argument.