Skip to content
Merged
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.24.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,7 @@ Timezones
- Bug in :meth:`DataFrame.any` returns wrong value when ``axis=1`` and the data is of datetimelike type (:issue:`23070`)
- Bug in :meth:`DatetimeIndex.to_period` where a timezone aware index was converted to UTC first before creating :class:`PeriodIndex` (:issue:`22905`)
- Bug in :meth:`DataFrame.tz_localize`, :meth:`DataFrame.tz_convert`, :meth:`Series.tz_localize`, and :meth:`Series.tz_convert` where ``copy=False`` would mutate the original argument inplace (:issue:`6326`)
- Bug in :meth:`DataFrame.max` and :meth:`DataFrame.min` with ``axis=1`` where a :class:`Series` with ``NaN`` would be returned when all columns contained the same timezone (:issue:`10390`)

Offsets
^^^^^^^
Expand Down
5 changes: 4 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
find_common_type)
from pandas.core.dtypes.common import (
is_dict_like,
is_datetime64tz_dtype,
is_object_dtype,
is_extension_type,
is_extension_array_dtype,
Expand Down Expand Up @@ -7390,7 +7391,9 @@ def f(x):
return op(x, axis=axis, skipna=skipna, **kwds)

# exclude timedelta/datetime unless we are uniform types
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 is_datetime64tz_dtype(self.dtypes[0]))):
numeric_only = True

if numeric_only is None:
Expand Down
13 changes: 13 additions & 0 deletions pandas/tests/reductions/test_reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@ def test_nanops(self):
assert obj.argmin(skipna=False) == -1
assert obj.argmax(skipna=False) == -1

@pytest.mark.parametrize('op, expected_col', [
['max', 'a'], ['min', 'b']
])
def test_same_tz_min_max_axis_1(self, op, expected_col):
# GH 10390
df = DataFrame(pd.date_range('2016-01-01 00:00:00', periods=3,
tz='UTC'),
columns=['a'])
df['b'] = df.a.subtract(pd.Timedelta(seconds=3600))
result = getattr(df, op)(axis=1)
expected = df[expected_col]
tm.assert_series_equal(result, expected)


class TestSeriesReductions(object):
# Note: the name TestSeriesReductions indicates these tests
Expand Down