-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: support datetime64, datetime64tz in nanops.mean, nanops.median #29941
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 1 commit
441502e
58ae39e
8c0e994
fb4a995
cb77a0d
169122d
406de1b
2473c60
9b3329e
1eafb5e
09b9d0a
52fd77d
385ae34
43cc784
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 |
---|---|---|
|
@@ -7575,6 +7575,19 @@ def _count_level(self, level, axis=0, numeric_only=False): | |
def _reduce( | ||
self, op, name, axis=0, skipna=True, numeric_only=None, filter_type=None, **kwds | ||
): | ||
|
||
dtype_is_dt = self.dtypes.apply(lambda x: x.kind == "M") | ||
if numeric_only is None and name in ["mean", "median"] and dtype_is_dt.any(): | ||
warnings.warn( | ||
jreback marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"DataFrame.mean and DataFrame.median with numeric_only=None " | ||
"will include datetime64 and datetime64tz columns in a " | ||
"future version.", | ||
FutureWarning, | ||
stacklevel=3, | ||
) | ||
cols = self.columns[~dtype_is_dt] | ||
self = self[cols] | ||
|
||
if axis is None and filter_type == "bool": | ||
labels = None | ||
constructor = None | ||
|
@@ -7614,8 +7627,10 @@ def _get_data(axis_matters): | |
# TODO: combine with hasattr(result, 'dtype') further down | ||
# hard since we don't have `values` down there. | ||
result = np.bool_(result) | ||
except TypeError: | ||
except (TypeError, ValueError): | ||
# e.g. in nanops trying to convert strs to float | ||
# TODO: the ValueError is raised in trying to convert str | ||
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 this should be a TypeError, where is the ValueError coming from? 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. what is trying to convert to str? 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. do you still need this ValueError? (as i think you changed below) 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'll re-run without catching ValueError. IIRC it was in nanops._ensure_numeric 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. yah, there are 3 tests where 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. just removed this and re-raised as TypeError on nanops 1292-1296 |
||
# to float, should we make that a TypError? | ||
|
||
# try by-column first | ||
if filter_type is None and axis == 0: | ||
|
Uh oh!
There was an error while loading. Please reload this page.