-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DataFrame.any(axis={0, 1}) returns inconsistent values for non-zero timedelta #17667
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
Comments
axis
I agree this behavior seems odd. I was surprised to discover that the code is explicitly checking for this situation. This is the relevant code: https://github.com/pandas-dev/pandas/blob/v0.20.3/pandas/core/frame.py#L5055
This check was added here, though I don't know why. |
|
This looks fixed on master. Could use a test.
|
@mroeschke: Should the test be specifically for this dataframe: df = pandas.DataFrame({'a': pandas.Series([0, 0]),
't': pandas.Series([pandas.to_timedelta(0, 's'), pandas.to_timedelta(1, 'ms')])})` |
@rohitsanj correct |
@mroeschke I've submitted a PR to add the test - #28942 |
Steps to reproduce
Problem description
pandas.DataFrame.any() returns "whether any element is True over the selected axis".
In the example above, the results of
df.any(axis=ax)
is clearly inconsistent for the two axis directions (cells [5] and [6]).If an element in column
"t"
leads to a result ofTrue
indf.any(axis=0)
, then the same element should lead to a result ofTrue
indf.any(axis=1)
.Expected output
As a user, I expected
DataFrame.any()
to return True for rows or columns with a non-zero timedelta value. That is, I expected atimedelta
column to have the same semantics as integers: zero values are treated as False, while other values are treated as True.In other words, this is the output I expected:
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: