-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: Make Series._values match Index._values #31182
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
Changes from all commits
11eff3e
d172ef5
3b22d7e
256a54e
91af806
95de06b
5fd52c4
75cb3f4
0c01488
c270efa
713bac2
324835c
2016b84
5395388
9601525
5c305ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1265,6 +1265,10 @@ def unique(self): | |
if hasattr(values, "unique"): | ||
|
||
result = values.unique() | ||
if self.dtype.kind in ["m", "M"] and isinstance(self, ABCSeries): | ||
# GH#31182 Series._values returns EA, unpack for backward-compat | ||
if getattr(self.dtype, "tz", None) is None: | ||
result = np.asarray(result) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a comment here on why this is needed |
||
else: | ||
result = unique1d(values) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -493,7 +493,8 @@ def _values(self): | |
""" | ||
Return the internal repr of this data (defined by Block.interval_values). | ||
This are the values as stored in the Block (ndarray or ExtensionArray | ||
depending on the Block class). | ||
depending on the Block class), with datetime64[ns] and timedelta64[ns] | ||
wrapped in ExtensionArrays to match Index._values behavior. | ||
|
||
Differs from the public ``.values`` for certain data types, because of | ||
historical backwards compatibility of the public attribute (e.g. period | ||
|
@@ -502,8 +503,9 @@ def _values(self): | |
cases). | ||
|
||
Differs from ``.array`` in that this still returns the numpy array if | ||
the Block is backed by a numpy array, while ``.array`` ensures to always | ||
return an ExtensionArray. | ||
the Block is backed by a numpy array (except for datetime64 and | ||
timedelta64 dtypes), while ``.array`` ensures to always return an | ||
ExtensionArray. | ||
|
||
Differs from ``._ndarray_values``, as that ensures to always return a | ||
numpy array (it will call ``_ndarray_values`` on the ExtensionArray, if | ||
|
@@ -515,8 +517,9 @@ def _values(self): | |
----------- | ------------- | ------------- | ------------- | --------------- | | ||
Numeric | ndarray | ndarray | PandasArray | ndarray | | ||
Category | Categorical | Categorical | Categorical | ndarray[int] | | ||
dt64[ns] | ndarray[M8ns] | ndarray[M8ns] | DatetimeArray | ndarray[M8ns] | | ||
dt64[ns] | ndarray[M8ns] | DatetimeArray | DatetimeArray | ndarray[M8ns] | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A bit above (beginning of the docstring), the sentence "This are the values as stored in the Block" is no longer adequate I think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The sentence I am quoting (the second line of the docstring) still needs to be updated |
||
dt64[ns tz] | ndarray[M8ns] | DatetimeArray | DatetimeArray | ndarray[M8ns] | | ||
td64[ns] | ndarray[m8ns] | TimedeltaArray| ndarray[m8ns] | ndarray[m8ns] | | ||
Period | ndarray[obj] | PeriodArray | PeriodArray | ndarray[int] | | ||
Nullable | EA | EA | EA | ndarray | | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.