31
31
32
32
from pandas .tseries .offsets import index_offsets_equal
33
33
import pandas .tseries .frequencies as frequencies
34
-
34
+ import pandas . core . indexes . api as _api
35
35
36
36
_index_doc_kwargs = dict (ibase ._index_doc_kwargs )
37
37
@@ -635,7 +635,8 @@ def intersection(self, other):
635
635
self ._assert_can_do_setop (other )
636
636
637
637
if self .equals (other ):
638
- return self ._get_consensus_name (other )
638
+ name = _api ._get_consensus_names ((self , other ))[0 ]
639
+ return self ._shallow_copy (self , name = name )
639
640
640
641
lengths = len (self ), len (other )
641
642
if lengths [0 ] == 0 :
@@ -648,7 +649,6 @@ def intersection(self, other):
648
649
not other ._is_strictly_monotonic )):
649
650
result = Index .intersection (self , other )
650
651
result = self ._shallow_copy (result ._values , name = result .name ,
651
- tz = getattr (self , 'tz' , None ),
652
652
freq = None
653
653
)
654
654
if result .freq is None :
@@ -657,9 +657,9 @@ def intersection(self, other):
657
657
658
658
# Conditions met!
659
659
intersected_slice = self ._fast_intersection (other )
660
- intersected = self . _shallow_copy ( intersected_slice )
661
- return intersected . _get_consensus_name ( other )
662
-
660
+ name = _api . _get_consensus_names (( self , other ))[ 0 ]
661
+ intersected = self . _shallow_copy ( intersected_slice , name = name )
662
+ return intersected
663
663
664
664
def wrap_arithmetic_op (self , other , result ):
665
665
if result is NotImplemented :
0 commit comments