Repository navigation
MNT use narwhals in indexable - #33959
Conversation
| elif _nw_is_into_df_or_series(iterable): | ||
| return nw.from_native(iterable) |
There was a problem hiding this comment.
All the tests use dataframes (polars, pandas, pyarrow) that have getitem.
- if we want to support other dataframes we should test them
- otherwise we should not include this line
There was a problem hiding this comment.
I changed the order, dataframes are converted to narwhals before getitem is checked because getitem has very different semantics for different dataframes.
|
#34051 needs to be merged first. |
|
@jeremiedbb Wanna merge? |
| def check_df(x): | ||
| return isinstance(x, input_type) or isinstance(x.to_native(), input_type) |
There was a problem hiding this comment.
So now we're going to have narwhals dataframes moving around in fit, which is fine. My concern is: are we sure that it does not surface to the user ? I believe we're safe in sklearn since we never return dataframes outside of set_output (do we ?). But 3rd party estimators might. I know you're going to argue that _make_indexable is private so we don't care, but still 😄.
There was a problem hiding this comment.
We have a convention what is public and what is private. If I can‘t rely on that convention as a developer, I‘ll stop contributing.
There was a problem hiding this comment.
@jeremiedbb Is this a blocker?
@adrinjalali once asked here
do you think you could drive this?
I said yes, but it needs community support. If we want to profit from narwhals, internal things will need to change.
There was a problem hiding this comment.
I think the "exposed to user" worry is reasonable, but pretty easy to handle:
- make sure we have a common test which checks for the output type, given different input types (I think we already have this?)
- if we want to really care about the return types of existing private methods, we can create a new method anywhere we want to do this kind of change. For instance, here we'd do
_make_nw_indexableinstead of changing existing one, and deprecate the old one. I think it's dirty, unnecessary, and adds avoidable maintenance burden, but doable. I'd be more in favor of not doing this.
There was a problem hiding this comment.
Thanks, @adrinjalali, for your input.
Expectations management: As a developer, I want to rely on our convention and not implement a new private API (_make_nw_indexable). I won't implement that, others can do this.
Personal impression: It feels like paranoia (and a waste of my time).
|
@jeremiedbb THX 🙏 |
|
Looks like this broke the doc build see build log for more details and error below. Remember to use |
|
@lesteve Thanks for the report. I think our tests are not good enough. It should not require a doc build. I can try to fix it in the coming days. |
Co-authored-by: Jérémie du Boisberranger <[email protected]>
Reference Issues/PRs
Contributes to #33958.
What does this implement/fix? Explain your changes.
Uses narwhals in
indexableinstead ofiloc.AI usage disclosure
None
Any other comments?