Description
Code Sample, a copy-pastable example if possible
This works when comparing two non-timezone datetime columns
a = pd.DataFrame(
{
"a": [pd.Timestamp("20180101"), np.nan],
"b": [pd.Timestamp("20190101"), pd.Timestamp("20190101")],
}
)
a.max(axis=1)
Output:
0 2019-01-01
1 2019-01-01
dtype: datetime64[ns]
But it fails on time-zone datetime columns
a = pd.DataFrame(
{
"a": [pd.Timestamp("20180101", tz="utc"), np.nan],
"b": [pd.Timestamp("20190101", tz="utc"), pd.Timestamp("20190101", tz="utc")],
}
)
a.max(axis=1)
Output:
0 NaN
1 NaN
dtype: float64
Problem description
I'm expecting the .max function to work consistently on both non-timezone and timezone datetime columns. But as the above results shows, somehow the comparison of timezone datetime is adjusted to float and the results are all nan.
Expected Output
Output of pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.7.4.final.0
python-bits : 64
OS : Windows
OS-release : 7
machine : AMD64
processor : Intel64 Family 6 Model 62 Stepping 4, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 0.25.1
numpy : 1.16.5
pytz : 2019.2
dateutil : 2.8.0
pip : 19.2.2
setuptools : 41.0.1
Cython : 0.29.13
pytest : 5.0.1
hypothesis : None
sphinx : None
blosc : None
feather : 0.4.0
xlsxwriter : 1.1.8
lxml.etree : 4.4.1
html5lib : 1.0.1
pymysql : 0.9.3
psycopg2 : None
jinja2 : 2.10.1
IPython : 7.8.0
pandas_datareader: 0.7.4
bs4 : 4.8.0
bottleneck : 1.2.1
fastparquet : None
gcsfs : None
lxml.etree : 4.4.1
matplotlib : 3.1.1
numexpr : 2.7.0
odfpy : None
openpyxl : 2.6.2
pandas_gbq : None
pyarrow : 0.11.1
pytables : None
s3fs : None
scipy : 1.3.1
sqlalchemy : 1.3.7
tables : 3.5.2
xarray : 0.12.1
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : 1.1.8