-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Support Polars DataFrames #1319
Comments
+1 for this one. Maybe adding an |
Just to make sure I understand the request correctly. We could implement the For an example, if we implemented
To be fair, you can get an R data.frame pretty easily by doing:
which will trigger We could also add an option to the Is that what you are suggesting? I don't have strong feelings about either option. However if we add |
Yes I am for an automatic py_to_r(). And definitely a parameter should be available for users. |
@OmarAshkar, do you have an example of some usage that automatic convertion is much nicer than calling |
@dfalbel Thanks for taking a look at this. What exactly would break? The fact that folks focusing on polars could remove steps in their work? If there are any breaks, I assume they would be quite happy about things being made simpler. It would definitely make writing tests for python/polars to be executed through reticulate much easier. |
I think what @dfalbel is suggesting is that users likely have existing workflows where they are expecting polars dataframes to not eagerly convert to R dataframes, (similar to how TensorFlow tensors don't automatically converting to R arrays, even when The most minimal changes I can think of, that won't break existing workflows, would be to add an |
We can also add a Today, if you want to pass a python bt <- import_builtins()
bt$slice(NULL) for example py$df[2, bt$slice(NULL)] |
The current version of reticulate brings slice support to This now works: ## slice a NumPy array
x <- np_array(array(1:64, c(4, 4, 4)))
# R expression | Python expression
# ------------ | -----------------
x[0] # x[0]
x[, 0] # x[:, 0]
x[, , 0] # x[:, :, 0]
x[NA:2] # x[:2]
x[`:2`] # x[:2]
x[2:NA] # x[2:]
x[`2:`] # x[2:]
x[NA:NA:2] # x[::2]
x[`::2`] # x[::2]
x[1:3:2] # x[1:3:2]
x[`1:3:2`] # x[1:3:2] See The same syntax should work for Polars DataFrames. |
Would love to see this as well! |
what's the status on this? currently, when using polars in quarto with revealjs, rendering is terrible. Is it possible to pre-process everything and use to_pandas without showing that? |
CC @cderv, do you have any thoughts about ☝🏻 ? |
I have been using Polars in Python and it is a wonderful, fast, DataFrame library for Python and Rust. There even seems to be work on creating R-bindings for polars as well (https://github.com/pola-rs/r-polars).
I use reticulate a lot in shiny apps and it would be great if reticulate could also support the Polars DataFrame format, at least in terms being able to convert a Polars DataFrame to an R data.frame. Since polars is based on Arrow, I hope this may be possible.
Below an example of what happens currently when using reticulate with a polars data.frame.
The text was updated successfully, but these errors were encountered: