-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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.round behavior with ExtensionArrays #26730
Comments
I think NumPy's new In the meantime, I'm not sure what's best. I'm not sure that adding an |
Sorry, I miswrote earlier. I said In that case, Series.round simply becomes |
yeah, that looks like the right solution. Still requires changes on pandas side though, no? |
Correct. And that's experimental in NumPy, and it requires work on the part
of the EA author to implement it. This is all very new :)
I'm not sure what a good short-term solution is. Possibly removing the call
to com.values_from_object in Series.round and seeing whether any tests
break?
…On Tue, Jun 11, 2019 at 2:17 PM pilkibun ***@***.***> wrote:
yeah, that looks like the right solution. Still requires changes on pandas
side though, no?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#26730?email_source=notifications&email_token=AAKAOIXL5EPQK4DTEFZX6PTPZ723DA5CNFSM4HWFT63KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXOGSLI#issuecomment-500984109>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKAOIQFES2MOOUU4FZMHPDPZ723DANCNFSM4HWFT63A>
.
|
I just coded it up, turned on experimental support in numpy 1.16.4 and it works (:balloon:). However,
and yet:
so maybe the |
Indeed, @jorisvandenbossche does your recent work on |
I think it is the docstring of
No, as that is using I agree the long term solution is that we want to use the numpy function protocol. In principle, I think we could already switch to |
The work I have been doing that Tom referenced is about getting rid of (first deprecating)
The reason of the bug is not necessarily |
That makes things clearer, thanks. So I understand The |
Yes, Similarly, for most EAs, |
wait what. |
See http://pandas.pydata.org/pandas-docs/stable/whatsnew/v0.24.0.html#whatsnew-0240-values-api, which was kind of the follow-up on the blog post you mentioned in the first post. Want an EA -> use |
ok. time for a PR? |
aside, shoyer in numpy/numpy#13759 (comment) pointed out this section in NEP-18. Quote:
That's a lot of boilerplate burden on EA developers, which tom mentioned earlier. |
But I suppose that you can still "fallback" inside |
If there's too much boilerplate for EA authors, we could perhaps provide a Mixin class implementing the fallback behavior. |
Ugh. I read through this thread 2x and followed a few of the links. Am I to understand that the solution is "don't use cc @hgrecco (pint developer) |
@TomAugspurger, in your blog post Moral Philosophy for pandas or: What is .values? you wrote
I just ran into an issue because this doesn't happen in some places.
pint is a popular package for working with units, useful for engineering/sci calculations. Recently they introduced an EA called pint-pandas for better interaction with pandas,
it's still a little rough, but very promising.
Here's an failure example:
The problem is that
Series.round()
callscom.values_from_object(self)
instead of the EA-awareself.values
.pandas/pandas/core/series.py
Lines 2054 to 2085 in cf25c5c
com.values_from_object(self)
percolates down to ExtensionBlock.to_dense():pandas/pandas/core/internals/blocks.py
Lines 1729 to 1730 in cf25c5c
Which calls
np.asarray(self.values)
, this convert the underlyingPintArray
in to a numpy array with object dtype, which is not numeric, and so numpy complains thatrint
isn't implemented. IfSeries.round()
would invokedround()
onself.values
directly, the underlying EA implementation would get a chance to implement a suitable method, or delegate to numpy in an appropriate way.You may want to make life easier for EA developers, by providing a default implementation for things like round(), I suppose it may work in some cases, but then there still needs to be a way for an EA to provide its own implementation of functions like
round
. ManySeries
methods usecom.values_from_object(self)
, and its the the same problem everywhere.cc @hgrecco (pint developer)
The text was updated successfully, but these errors were encountered: