Skip to content

Commit 37cbf25

Browse files
author
Albert Villanova del Moral
committed
Create new DatetimeIndex from the Index.intersection result
1 parent 8598ec2 commit 37cbf25

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pandas/tseries/index.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1202,9 +1202,9 @@ def intersection(self, other):
12021202
not other.offset.isAnchored() or
12031203
(not self.is_monotonic or not other.is_monotonic)):
12041204
result = Index.intersection(self, other)
1205-
if isinstance(result, DatetimeIndex):
1206-
if result.freq is None:
1207-
result.offset = to_offset(result.inferred_freq)
1205+
result = self._simple_new(result._values, name=result.name, tz=result.tz)
1206+
if result.freq is None:
1207+
result.offset = to_offset(result.inferred_freq)
12081208
return result
12091209

12101210
if len(self) == 0:

0 commit comments

Comments
 (0)