42
42
import pandas .tseries .frequencies as frequencies
43
43
from pandas .util ._decorators import Appender , cache_readonly
44
44
import pandas .core .dtypes .concat as _concat
45
-
45
+ import pandas . core . indexes . api as _api
46
46
47
47
import pandas .core .indexes .base as ibase
48
48
_index_doc_kwargs = dict (ibase ._index_doc_kwargs )
@@ -804,7 +804,8 @@ def intersection(self, other):
804
804
self ._assert_can_do_setop (other )
805
805
806
806
if self .equals (other ):
807
- return self ._get_consensus_name (other )
807
+ name = _api ._get_consensus_names ((self , other ))[0 ]
808
+ return self ._shallow_copy (self , name = name )
808
809
809
810
lengths = len (self ), len (other )
810
811
if lengths [0 ] == 0 :
@@ -817,7 +818,6 @@ def intersection(self, other):
817
818
not other ._is_strictly_monotonic )):
818
819
result = Index .intersection (self , other )
819
820
result = self ._shallow_copy (result ._values , name = result .name ,
820
- tz = getattr (self , 'tz' , None ),
821
821
freq = None
822
822
)
823
823
if result .freq is None :
@@ -826,9 +826,9 @@ def intersection(self, other):
826
826
827
827
# Conditions met!
828
828
intersected_slice = self ._fast_intersection (other )
829
- intersected = self . _shallow_copy ( intersected_slice )
830
- return intersected . _get_consensus_name ( other )
831
-
829
+ name = _api . _get_consensus_names (( self , other ))[ 0 ]
830
+ intersected = self . _shallow_copy ( intersected_slice , name = name )
831
+ return intersected
832
832
833
833
def _ensure_datetimelike_to_i8 (other , to_utc = False ):
834
834
"""
0 commit comments