Open rollo-b2c2 opened 1 year ago
We don't expose that functionality as that is not the way polars should be used. We never have needed it ourselves internally.
Even on small data, the idiomatic use case of polars is using the lazy API and create your queries with the DSL.
I've used Polaris to do an aggregation of data. This returns a small dataframe. There's an existing UI API that wants Rows of data not columns.
What is the idiomatic way of giving the data back to the user?
not the way polars should be used
Are you saying Polars should not be used to aggregate data which is sent to a UI in a row-wise format? 😕 Like I'd like to add Polaris into my stack, but I'm not designing a project around it, I'm integrating it into one.
https://stackoverflow.com/questions/72440403/iterate-over-rows-polars-rust
Like I'm not the only person who'd find this useful (everyone using this project would be aware that it's slower than saving to arrow, but the world doesn't run on Arrow.)
I find it useful to keep a small crate of functions that hide some of the verbose APIs. The API hasn't changed much in the last year in my experience.
For example, when I need to iterate over rows to do some math and generate multiple columns, I would use the map/map_many interface and maybe flatten a struct column. Sometimes not just interface, but math requires row-wise iteration, such as with digital filtering. The user defined functions still allow access to the data in row order efficiently.
I don't think digital filtering belongs supported within Polars, and Polars doesn't prevent implementing it efficiently. Ergonomic row-wise iteration seems to me to be in the same category because Polars intentionally doesn't implement it efficiently, even though there is need for row-wise iteration.
Problem description
The only way I can see to iter rows in Rust is this little monstrosity.
It would just make a lot of sense to have iter rows in Rust. I get it's not how Arrow likes to be accessed. But there's a lot of usecases for it. Lets say you're running an aggregation on a server that outputs a small (under 100row) table, being able to send row wise results just makes it easier to integrate polars into existing APIs that might not be columnar.