-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
REF: avoid _internal_get_values in json get_values #32754
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
Conversation
Pretty much everything right now goes into |
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.
Nice simplification!
@@ -222,13 +222,19 @@ static PyObject *get_values(PyObject *obj) { | |||
|
|||
PRINTMARK(); | |||
|
|||
if (PyObject_HasAttrString(obj, "_internal_get_values")) { | |||
if (PyObject_TypeCheck(obj, cls_index) || PyObject_TypeCheck(obj, cls_series)) { |
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 guess will see on test cases, but is this really required? AFAICT on master _internal_get_values
and values
return the same for a dt64tz array:
>>> dts = pd.date_range(start="2020-01-01", freq="D", periods=3, tz="US/Pacific")
>>> dts._internal_get_values()
array(['2020-01-01T08:00:00.000000000', '2020-01-02T08:00:00.000000000',
'2020-01-03T08:00:00.000000000'], dtype='datetime64[ns]')
>>> dts.values
array(['2020-01-01T08:00:00.000000000', '2020-01-02T08:00:00.000000000',
'2020-01-03T08:00:00.000000000'], dtype='datetime64[ns]')
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.
its Categorical[dt64tz] and Sparse that make the extra __array__
call necessary
lgtm. happy if you guys are. |
Thanks @jbrockmendel |
cc @WillAyd
As mentioned in #32731, this changes the behavior for CategoricalIndex[dt64tz] and Series with that for its index. Suggestions for where tests for that should go?
Note: the Categorical[dt64tz] cases still do a trip through object-dtype; I don't want to futz with that in C-space.