-
Notifications
You must be signed in to change notification settings - Fork 126
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
Add Series.drop_nil #864
Comments
Do we need the regular version of this? It feels like clutter. The idea of minimal verbs is that you can do everything you need with them. Why not just |
Just thinking out loud here: I think there's got to be a more elegant way of dealing with lists than cleaving to Polars's API too closely. I'm not sure I like everything about There's also |
@cigrainger you are right, we don't need
|
Maybe. I need to explore how Polars handles this itself and in py polars. |
So putting this a bit to the test with Python Polars: It seems like nested lists may not be supported? That would fix the recursion problem pretty cleanly. In [16]: df = pl.DataFrame({"values": [[None, 1, None, 2], [None], [3, 4], [[None, 1], [2], [None]]]})
In [17]: df
Out[17]:
shape: (4, 1)
┌────────────────────┐
│ values │
│ --- │
│ list[i64] │
╞════════════════════╡
│ [null, 1, … 2] │
│ [null] │
│ [3, 4] │
│ [null, null, null] │
└────────────────────┘ |
@cigrainger all lists need to be nested equally. When it fails to cast to a certain type, it returns |
@cigrainger Also, in case you missed it, there was an interesting saga of us discovering what Polars was doing WRT nested lists here: Some take-aways:
|
I did! Thanks @billylanchantin |
There are two possible versions of this function:
We need to decide the API. If we call it
drop_nil/1
for series, how would we call it the list version? We could use thelist_
prefix but we have generally avoided those.Another option is to pass an atom to
drop_nil/2
, such asSeries.drop_nil(series, :list)
but then I am not sure how to call the regular version. Ideas are welcome.The text was updated successfully, but these errors were encountered: