-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
DEPR: deprecate publicfacing .asobject #18477
Changes from all commits
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 |
---|---|---|
|
@@ -369,7 +369,7 @@ def unique(values): | |
# to return an object array of tz-aware Timestamps | ||
|
||
# TODO: it must return DatetimeArray with tz in pandas 2.0 | ||
uniques = uniques.asobject.values | ||
uniques = uniques._asobject.values | ||
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. change usage to |
||
|
||
return uniques | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -358,7 +358,7 @@ def map(self, f): | |
raise TypeError('The map function must return an Index object') | ||
return result | ||
except Exception: | ||
return self.asobject.map(f) | ||
return self._asobject.map(f) | ||
|
||
def sort_values(self, return_indexer=False, ascending=True): | ||
""" | ||
|
@@ -421,15 +421,23 @@ def _isnan(self): | |
return (self.asi8 == iNaT) | ||
|
||
@property | ||
def asobject(self): | ||
def _asobject(self): | ||
""" | ||
return object Index which contains boxed values | ||
|
||
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. remove this entirely |
||
*this is an internal non-public method* | ||
Return object Index which contains boxed values | ||
""" | ||
from pandas.core.index import Index | ||
return Index(self._box_values(self.asi8), name=self.name, dtype=object) | ||
|
||
@property | ||
def asobject(self): | ||
"""DEPRECATED: Use 'astype(object).values' instead. | ||
|
||
Return object Index which contains boxed values | ||
""" | ||
warnings.warn("'.asobject' is deprecated. Use 'astype(object).values'" | ||
" instead", FutureWarning, stacklevel=2) | ||
return self._asobject | ||
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.
|
||
|
||
def _convert_tolerance(self, tolerance, target): | ||
tolerance = np.asarray(to_timedelta(tolerance, box=False)) | ||
if target.size != tolerance.size and tolerance.size > 1: | ||
|
@@ -466,7 +474,7 @@ def tolist(self): | |
""" | ||
return a list of the underlying data | ||
""" | ||
return list(self.asobject) | ||
return list(self._asobject) | ||
|
||
def min(self, axis=None, *args, **kwargs): | ||
""" | ||
|
@@ -744,7 +752,7 @@ def isin(self, values): | |
try: | ||
values = type(self)(values) | ||
except ValueError: | ||
return self.asobject.isin(values) | ||
return self._asobject.isin(values) | ||
|
||
return algorithms.isin(self.asi8, values.asi8) | ||
|
||
|
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 just
.astype(object)
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.
It you follow the call chain down it translates to
ser._data.blocks[0].values.astype(object)
. So I'd say it should be "use.values.astype(object)
", which is an ndarray, while.astype(object)
returns a Series.I'll use the form
.values.astype(object)
, unless you comment