-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: DataFrame.min/max with axis=1 and uniform datetime64[ns, tz] types does not return NaNs #24759
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
Conversation
pandas/core/generic.py
Outdated
@@ -5164,6 +5164,11 @@ def _is_datelike_mixed_type(self): | |||
f = lambda: self._data.is_datelike_mixed_type | |||
return self._protect_consolidate(f) | |||
|
|||
@property |
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.
you shouldn't need this as _is_datelike_mixed_type
should cover this case, no?
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.
_is_datelike_mixed_type
is not specific to tz-aware blocks nor checks the actual timezone which we need here
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.
Can you instead use self._is_homogenous_type
and a check that any (or the first) dtype is datetimetz
?
pandas/tests/frame/test_timezones.py
Outdated
@@ -196,3 +196,15 @@ def test_tz_localize_convert_copy_inplace_mutate(self, copy, method, tz): | |||
index=date_range('20131027', periods=5, | |||
freq='1H', tz=tz)) | |||
tm.assert_frame_equal(result, expected) | |||
|
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.
these should go with the appropriate tests, I think in test_nanops or maybe tests/reductions)
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.
Sure. Moved to tests/reductions
Codecov Report
@@ Coverage Diff @@
## master #24759 +/- ##
===========================================
- Coverage 92.38% 42.92% -49.47%
===========================================
Files 166 166
Lines 52363 52373 +10
===========================================
- Hits 48376 22480 -25896
- Misses 3987 29893 +25906
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #24759 +/- ##
==========================================
+ Coverage 92.38% 92.38% +<.01%
==========================================
Files 166 166
Lines 52363 52366 +3
==========================================
+ Hits 48377 48380 +3
Misses 3986 3986
Continue to review full report at Codecov.
|
pandas/core/frame.py
Outdated
if axis == 1 and self._is_mixed_type and self._is_datelike_mixed_type: | ||
if (axis == 1 and self._is_datelike_mixed_type | ||
and (not self._is_homogeneous_type | ||
and not self._data.blocks[0].is_datetimetz)): |
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.
really don't like the last condition as this is reaching into internals. are the prior ones not sufficient?
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.
Alternative is is_datetimetz64_dtype(self.dtypes[0])
. I don't have a preference on which is cleaner.
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.
Opted for your suggestion @TomAugspurger. Looks a little cleaner from first inspection.
thanks @mroeschke |
…es does not return NaNs (pandas-dev#24759)
…es does not return NaNs (pandas-dev#24759)
git diff upstream/master -u -- "*.py" | flake8 --diff
Essentially, check that all blocks are are datetimetz type and the same timezone before performing
max
/min
since datetimetz blocks are only 1D