BUG: DTI.intersection doesnt preserve tz by sinhrks · Pull Request #7458 · pandas-dev/pandas (original) (raw)
Also, found and fixed a bug which non-monotonic Index.union
incorrectly preserves name
when Index
have different names.
# monotonic
idx1 = pd.Index([1, 2, 3, 4, 5], name='idx1')
idx2 = pd.Index([4, 5, 6, 7, 8], name='other')
idx1.intersection(idx2).name
# None (Expected)
# non-monotonic
idx1 = pd.Index([5, 4, 3, 2, 1], name='idx1')
idx2 = pd.Index([4, 5, 6, 7, 8], name='other')
idx1.intersection(idx2).name
# idx1