-
-
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 3 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 |
---|---|---|
|
@@ -743,7 +743,16 @@ def array(self) -> ExtensionArray: | |
[a, b, a] | ||
Categories (2, object): [a, b] | ||
""" | ||
raise AbstractMethodError(self) | ||
# As a mixin, we depend on the mixing class having _values. | ||
# Special mixin syntax may be developed in the future: | ||
# https://github.com/python/typing/issues/246 | ||
result = self._values # type: ignore | ||
if isinstance(result, np.ndarray): | ||
from pandas.core.arrays.numpy_ import PandasArray | ||
|
||
result = PandasArray(result) | ||
|
||
return result | ||
|
||
def to_numpy(self, dtype=None, copy=False, na_value=lib.no_default, **kwargs): | ||
""" | ||
|
@@ -1249,6 +1258,9 @@ def unique(self): | |
if hasattr(values, "unique"): | ||
|
||
result = values.unique() | ||
if self.dtype.kind in ["m", "M"]: | ||
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 |
---|---|---|
|
@@ -377,7 +377,10 @@ def extract_array(obj, extract_numpy: bool = False): | |
array([1, 2, 3]) | ||
""" | ||
if isinstance(obj, (ABCIndexClass, ABCSeries)): | ||
obj = obj.array | ||
arr = obj._values | ||
if not extract_numpy and isinstance(arr, np.ndarray): | ||
return obj.array | ||
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. Yes, I was also just thinking while looking above at the Could also do a |
||
return arr | ||
|
||
if extract_numpy and isinstance(obj, ABCPandasArray): | ||
obj = obj.to_numpy() | ||
|
Uh oh!
There was an error while loading. Please reload this page.