-
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
feat: deprecate Expr.head, Expr.tail, Expr.sort, Expr.gather_every, Expr.sample (but keep them in stable.v1) #1791
feat: deprecate Expr.head, Expr.tail, Expr.sort, Expr.gather_every, Expr.sample (but keep them in stable.v1) #1791
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
5b92ccb
to
20ef637
Compare
def test_head( | ||
def test_tail( |
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.
lol
20ef637
to
655616e
Compare
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.
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 am all in favor for deprecating head, tail and gather every. I still think that sort
and sample
might have valid use cases, although hard/impossible to implement in some backends
@@ -21,6 +22,9 @@ def test_gather_every_expr( | |||
|
|||
assert_equal_data(result, expected) | |||
|
|||
with pytest.deprecated_call(): |
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.
TIL!
thanks all for feedback and for taking a look! i think more than implementation difficulties they're just not relational, e.g. In [16]: df
Out[16]:
shape: (3, 2)
┌───────┬─────┐
│ name ┆ age │
│ --- ┆ --- │
│ str ┆ i64 │
╞═══════╪═════╡
│ Mario ┆ 31 │
│ Luigi ┆ 32 │
│ Wario ┆ 45 │
└───────┴─────┘
In [17]: df.select('name', pl.col('age').sort(descending=True))
Out[17]:
shape: (3, 2)
┌───────┬─────┐
│ name ┆ age │
│ --- ┆ --- │
│ str ┆ i64 │
╞═══════╪═════╡
│ Mario ┆ 45 │
│ Luigi ┆ 32 │
│ Wario ┆ 31 │
└───────┴─────┘ you end up with tuples which aren't part of the original object - it's fine for Polars to allow it, but I'm not sure we should be allowing this kind of operation in Narwhals In any case, happy to bring these back if use cases do come along! |
One step closer to
narwhals.stable.v2
These are some operations which we won't be able to support in the lazy layer at all, and I think it would be confusing to have some Expr methods which aren't available at all for lazyframes (which would be different to
Expr.unique
, which could be supported if followed by an aggregation, orExpr.cum_sum
, which could be supported iforder_by
is passed)Further, I just don't think any of these expressions are very useful...people call head/tail/sort/sample on dataframes, not typically on individual expressions..
For the cases where people need them, they can use DataFrame or Series operations
What type of PR is this? (check all applicable)
Related issues
Checklist
If you have comments or can explain your changes, please do so below