-
-
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 get_values #26409
DEPR: deprecate get_values #26409
Changes from 9 commits
11c1f07
590b5f5
61c3275
f96b352
4931b9c
10cce45
10f92b1
b32d87b
fc87513
5f1bca4
19093e3
ec370af
1a7f644
d6a9542
ae22440
1a32d54
990c72c
064aeb4
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 |
---|---|---|
|
@@ -179,6 +179,9 @@ def get_values(self, dtype=None): | |
return self.values.astype(object) | ||
return self.values | ||
|
||
def get_block_values(self, dtype=None): | ||
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. we really need this? 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. is this still needed? 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. Well, the JSON C code does handle blocks (if I remove the 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. Opened #27164 for follow-up on this JSON issue |
||
return self.get_values(dtype=dtype) | ||
|
||
def to_dense(self): | ||
return self.values.view() | ||
|
||
|
@@ -2915,7 +2918,7 @@ def to_dense(self): | |
# Categorical.get_values returns a DatetimeIndex for datetime | ||
# categories, so we can't simply use `np.asarray(self.values)` like | ||
# other types. | ||
return self.values.get_values() | ||
return self.values._internal_get_values() | ||
|
||
def to_native_types(self, slicer=None, na_rep='', quoting=None, **kwargs): | ||
""" convert to our native types format, slicing if desired """ | ||
|
@@ -3216,6 +3219,7 @@ def _putmask_preserve(nv, n): | |
dtype, _ = maybe_promote(n.dtype) | ||
|
||
if is_extension_type(v.dtype) and is_object_dtype(dtype): | ||
# ? | ||
v = v.get_values(dtype) | ||
else: | ||
v = v.astype(dtype) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,15 +162,15 @@ def test_values(self): | |
|
||
exp = np.array([], dtype=np.object) | ||
tm.assert_numpy_array_equal(idx.values, exp) | ||
tm.assert_numpy_array_equal(idx.get_values(), exp) | ||
#tm.assert_numpy_array_equal(idx.get_values(), exp) | ||
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 and/or use filterwarnings on the test 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. lol, this is what's failing :_.> |
||
exp = np.array([], dtype=np.int64) | ||
tm.assert_numpy_array_equal(idx._ndarray_values, exp) | ||
|
||
idx = pd.PeriodIndex(['2011-01', pd.NaT], freq='M') | ||
|
||
exp = np.array([pd.Period('2011-01', freq='M'), pd.NaT], dtype=object) | ||
tm.assert_numpy_array_equal(idx.values, exp) | ||
tm.assert_numpy_array_equal(idx.get_values(), exp) | ||
#tm.assert_numpy_array_equal(idx.get_values(), exp) | ||
exp = np.array([492, -9223372036854775808], dtype=np.int64) | ||
tm.assert_numpy_array_equal(idx._ndarray_values, exp) | ||
|
||
|
@@ -179,7 +179,7 @@ def test_values(self): | |
exp = np.array([pd.Period('2011-01-01', freq='D'), pd.NaT], | ||
dtype=object) | ||
tm.assert_numpy_array_equal(idx.values, exp) | ||
tm.assert_numpy_array_equal(idx.get_values(), exp) | ||
#tm.assert_numpy_array_equal(idx.get_values(), exp) | ||
exp = np.array([14975, -9223372036854775808], dtype=np.int64) | ||
tm.assert_numpy_array_equal(idx._ndarray_values, exp) | ||
|
||
|
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.
Should I be concerned that CI is passing with this here? :)
Perhaps we need a test ensuring that
Categorical.get_values()
raises a warning.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.
No, that's a good sign :)
As that was my way to find all the places where it was being called, to fix those (although it is not a perfect way, as in certain places the error could also be catched)
But for sure still need to convert this into a warning and add tests that checks that.