-
Notifications
You must be signed in to change notification settings - Fork 121
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
Series.row_index/1 #862
Series.row_index/1 #862
Conversation
9fb0d96
to
cd8f0a3
Compare
Thank you @iurimateus. Quick question: do we need to use expr_len? couldn't we use |
@iurimateus I think |
For the record, these changes were before we had
Thanks for pointing it out, I was following py-polars implementation of using
That works, I've pushed a new commit. Thoughts on |
I would prefer to postpone int_range for now. So let's remove it from the Elixir side but we can still keep it on the Rust side. We also need to list explorer/lib/explorer/backend/series.ex Line 41 in b901d97
And then provide an implementation for regular series (which will basically return a list of u32). |
lib/explorer/series.ex
Outdated
@@ -6024,6 +6024,14 @@ defmodule Explorer.Series do | |||
def member?(%Series{dtype: dtype}, _value), | |||
do: dtype_error("member?/2", dtype, [{:list, :_}]) | |||
|
|||
def row_index(%Series{} = series) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add docs here. :)
def row_index(series) do | ||
Explorer.DataFrame.new(series: series) | ||
|> Explorer.DataFrame.mutate_with(&[row_index: Series.row_index(&1[:series])]) | ||
|> Explorer.DataFrame.pull(:row_index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should expose this function in Rust instead? https://docs.rs/polars/latest/polars/datatypes/struct.UInt32Type.html#method.new 🤔 would it have any performance difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(And perhaps new(lazy: true)
, but I'm not sure about allocations...)
Thanks for the reference, I've pushed a commit exposing it in Rust.
I'll rebase after review.
Awesome job. I have pushed one last comment and I think we are good to go! |
💚 💙 💜 💛 ❤️ |
Originally posted by @josevalim in #833 (comment)
@josevalim is this what you had in mind? I think it's the first
/0
function in Series; I'm also not sure on the implementation.Should we rename
len()
tosize()
for consistency?cc @cigrainger