-
Notifications
You must be signed in to change notification settings - Fork 16
Description
@MarcoGorelli
As mentionned today after your very good talk at pydata Paris, this tutorial repo is so useful 👍
My suggetion is to add an example of a function taking as input n columns and returning m colums.
It seems to me as generic as can be for row-wise functions.
The steps would be:
- python: create a column col_in of type struct {col_in_1: _, col_in_1: _, ..., col_in_n: _ } from cols col_1, col_2,... col_n
- plugin: create a plugin with Rust code unpacking the struct col in n variables with their own type
- Rust: apply a function with
- input Struct{col_in_1, col_in_1, ..., col_in_n}
- output Struct{col_out_1, col_out_1, ..., col_out_m}
- Remark: this function can be from an existing crate e.g. a back scholes option pricer - closer to real life example than toy local function
- plugin: return the Struct so that polars creates a col_out of type struct
- python: convert column col_out in m columns col_out_1, col_out_2, ..., col_out_m
The benefits would be - pls correct if/where wrong:
- 100% generic for a row-wise functions
- efficient as creating/expanding a struct column from/into regular columns is cheap in polars
The next and last question would be how to take in all data in one go as a vect (length L) of struct from the Rust side (I mean as opposed to row by row) and return a L-long vect of struct to create a full polars series. Unless I miss something this would literally cover all cases ! It would be a template for all potential plugins "row-wise" or "whole". It would be invaluable !!
The "glue" code between "polars Rust" and "generic Rust" is the difficult, least documented part, so the harder to discover for users willing to expand polars with plugins.
What do you think ?