I am extending the polars
DataFrame and LazyFrame as described in the docs.
Let’s go with their split
example for pl.DataFrame
. Let’s say I also wanted to extend the pl.LazyFrame
with the same split
function.
The code would look pretty much the same, with the exception of the decorator (@pl.api.register_dataframe_namespace("split")
vs. @pl.api.register_lazyframe_namespace("split")
, the input argument (df
vs. ldf
) and the return type (list[pl.DataFrame]
vs. list[pl.LazyFrame]
).
This looks pretty much violating the DRY mantra.
What is best-practice to extend the API on multiple fronts (DataFrame, LazyFrame, Series)?