DatetimeIndex.union with tz-aware and tz-naive raises TypeError · Issue #21671 · pandas-dev/pandas (original) (raw)
xref #11351
In [28]: s = pd.Series([pd.Timestamp('2011-01-01'), pd.NaT])
In [29]: stz = pd.Series(pd.DatetimeIndex(['2012-01-01', '2012-01-02'], tz='Asia/Tokyo'))
In [30]: pd.Index(s).union(pd.Index(stz))
TypeError: Cannot join tz-naive with tz-aware DatetimeIndex
In [32]: pd.__version__
Out[32]: '0.24.0.dev0+192.g0b63e81.dirty'
Problem description
Per #11351 (comment), this operation should just convert the data to object and not raise a TypeError.
Expected
In [33]: pd.Index(s).append(pd.Index(stz))
Out[33]:
Index([2011-01-01 00:00:00, NaT, 2012-01-01 00:00:00+09:00,
2012-01-02 00:00:00+09:00],
dtype='object')