-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: avoid values_from_object in Series #32426
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
2d8a274
ec7d005
cf6466b
29c785b
45a278f
fb6c6ff
200ac68
09c7354
da451a1
1017b08
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 |
---|---|---|
|
@@ -1984,7 +1984,7 @@ def idxmin(self, axis=0, skipna=True, *args, **kwargs): | |
nan | ||
""" | ||
skipna = nv.validate_argmin_with_skipna(skipna, args, kwargs) | ||
i = nanops.nanargmin(com.values_from_object(self), skipna=skipna) | ||
i = nanops.nanargmin(self._values, skipna=skipna) | ||
if i == -1: | ||
return np.nan | ||
return self.index[i] | ||
|
@@ -2055,7 +2055,7 @@ def idxmax(self, axis=0, skipna=True, *args, **kwargs): | |
nan | ||
""" | ||
skipna = nv.validate_argmax_with_skipna(skipna, args, kwargs) | ||
i = nanops.nanargmax(com.values_from_object(self), skipna=skipna) | ||
i = nanops.nanargmax(self._values, skipna=skipna) | ||
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. nanargmax/nanargmin expect to get an ndarray. Due to this change, it is no longer guaranteed to be an ndarray. Reported this as #32749 So those lines should either be reverted, or another "convert to ndarray" function should be used (or nanargmax/nanargmin could be rewritten to support EAs, but personally I think it is much cleaner to keep those algos based on numpy arrays) 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. @jbrockmendel can you respond to 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.
I'd be fine with either of these options. Probably prefer both actually: a EA-supporting public method and an ndarray-only private method for each of the relevant nanops funcs. |
||
if i == -1: | ||
return np.nan | ||
return self.index[i] | ||
|
@@ -2093,7 +2093,7 @@ def round(self, decimals=0, *args, **kwargs) -> "Series": | |
dtype: float64 | ||
""" | ||
nv.validate_round(args, kwargs) | ||
result = com.values_from_object(self).round(decimals) | ||
result = self._values.round(decimals) | ||
result = self._constructor(result, index=self.index).__finalize__(self) | ||
|
||
return result | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -875,11 +875,6 @@ def test_mean_datetimelike(self): | |
expected = pd.Series({"A": 1.0, "C": df.loc[1, "C"]}) | ||
tm.assert_series_equal(result, expected) | ||
|
||
@pytest.mark.xfail( | ||
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. I guess you should technically have a whatsnew note as this 'bug' is fixed (do in followon) |
||
reason="casts to object-dtype and then tries to add timestamps", | ||
raises=TypeError, | ||
strict=True, | ||
) | ||
def test_mean_datetimelike_numeric_only_false(self): | ||
df = pd.DataFrame( | ||
{ | ||
|
Uh oh!
There was an error while loading. Please reload this page.