Open markfairbanks opened 2 years ago
Another option: https://github.com/pola-rs/polars/pull/5531
This would allow using a tp
namespace on a polars data frame
df = pl.DataFrame({"a": [1, 2], "b": [3, 4]})
(
df
.tp.mutate(double_a = col('a') * 2)
.tp.filter(col('a') < 3)
.tp.arrange('a', 'b')
)
I think a tidy
namespace would be great here, now that you can register them - it's ideal for library authors as you get to extend the relevant classes without subclassing/mixins, or requiring changes in the core, and you are better protected from changes to the internals.
Plus: proper autocomplete :)
The <<
and >>
operators may get used for bitshift ops (their usual meaning), so I would consider them as being reserved for future polars/core use, rather than as a potential API extension point for external packages - otherwise you might get broken again :(
FYI, docs/examples relating to namespace registration are live, though you'll need to wait for >= 0.14.29
to use: https://pola-rs.github.io/polars/py-polars/html/reference/api.html
Thanks for the info @alexander-beedie 😄
The
<<
and>>
operators may get used for bitshift ops (their usual meaning), so I would consider them as being reserved for future polars/core use, rather than as a potential API extension point for external packages - otherwise you might get broken again :(
This has been my worry and why I hadn't updated tidypolars
with this yet. The new feature you implemented in https://github.com/pola-rs/polars/pull/5531 seems like a much better way to go.
This has been my worry and why I hadn't updated
tidypolars
with this yet. The new feature you implemented in pola-rs/polars#5531 seems like a much better way to go.
And it's available now - new version released a few hours ago ;)
Proposed interface:
Positives:
Negatives: