diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index d9b53aa4a867c..8383b783d90e7 100644 --- a/pandas/core/arrays/period.py +++ b/pandas/core/arrays/period.py @@ -33,6 +33,7 @@ from pandas.core.dtypes.dtypes import PeriodDtype from pandas.core.dtypes.generic import ( ABCIndexClass, + ABCPeriod, ABCPeriodArray, ABCPeriodIndex, ABCSeries, @@ -960,8 +961,8 @@ def _get_ordinal_range(start, end, periods, freq, mult=1): if end is not None: end = Period(end, freq) - is_start_per = isinstance(start, Period) - is_end_per = isinstance(end, Period) + is_start_per = isinstance(start, ABCPeriod) + is_end_per = isinstance(end, ABCPeriod) if is_start_per and is_end_per and start.freq != end.freq: raise ValueError("start and end must have same freq") diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 22ba317e78e63..95cfab4c96af3 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -3582,8 +3582,8 @@ def _join_multi(self, other, how, return_indexers=True): if not overlap: raise ValueError("cannot join with no overlapping index names") - self_is_mi = isinstance(self, MultiIndex) - other_is_mi = isinstance(other, MultiIndex) + self_is_mi = isinstance(self, ABCMultiIndex) + other_is_mi = isinstance(other, ABCMultiIndex) if self_is_mi and other_is_mi: diff --git a/pandas/core/reshape/concat.py b/pandas/core/reshape/concat.py index b42497b507e1f..8829c242b1129 100644 --- a/pandas/core/reshape/concat.py +++ b/pandas/core/reshape/concat.py @@ -1,5 +1,5 @@ """ -concat routines +Concat routines. """ from typing import Hashable, Iterable, List, Mapping, Optional, Union, overload @@ -8,6 +8,8 @@ from pandas._typing import FrameOrSeriesUnion +from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries + from pandas import DataFrame, Index, MultiIndex, Series from pandas.core.arrays.categorical import ( factorize_from_iterable, @@ -394,11 +396,11 @@ def __init__( axis = sample._get_axis_number(axis) # Need to flip BlockManager axis in the DataFrame special case - self._is_frame = isinstance(sample, DataFrame) + self._is_frame = isinstance(sample, ABCDataFrame) if self._is_frame: axis = 1 if axis == 0 else 0 - self._is_series = isinstance(sample, Series) + self._is_series = isinstance(sample, ABCSeries) if not 0 <= axis <= sample.ndim: raise AssertionError( "axis must be between 0 and {ndim}, input was " diff --git a/pandas/io/formats/excel.py b/pandas/io/formats/excel.py index b0e8e4033edf2..14e79538541af 100644 --- a/pandas/io/formats/excel.py +++ b/pandas/io/formats/excel.py @@ -14,7 +14,7 @@ from pandas.core.dtypes import missing from pandas.core.dtypes.common import is_float, is_scalar -from pandas.core.dtypes.generic import ABCMultiIndex, ABCPeriodIndex +from pandas.core.dtypes.generic import ABCIndex, ABCMultiIndex, ABCPeriodIndex from pandas import Index import pandas.core.common as com @@ -452,7 +452,7 @@ def _format_header_mi(self): "index ('index'=False) is not yet implemented." ) - has_aliases = isinstance(self.header, (tuple, list, np.ndarray, Index)) + has_aliases = isinstance(self.header, (tuple, list, np.ndarray, ABCIndex)) if not (has_aliases or self.header): return @@ -500,7 +500,7 @@ def _format_header_mi(self): self.rowcounter = lnum def _format_header_regular(self): - has_aliases = isinstance(self.header, (tuple, list, np.ndarray, Index)) + has_aliases = isinstance(self.header, (tuple, list, np.ndarray, ABCIndex)) if has_aliases or self.header: coloffset = 0 @@ -550,7 +550,7 @@ def _format_body(self): return self._format_regular_rows() def _format_regular_rows(self): - has_aliases = isinstance(self.header, (tuple, list, np.ndarray, Index)) + has_aliases = isinstance(self.header, (tuple, list, np.ndarray, ABCIndex)) if has_aliases or self.header: self.rowcounter += 1 @@ -590,7 +590,7 @@ def _format_regular_rows(self): yield cell def _format_hierarchical_rows(self): - has_aliases = isinstance(self.header, (tuple, list, np.ndarray, Index)) + has_aliases = isinstance(self.header, (tuple, list, np.ndarray, ABCIndex)) if has_aliases or self.header: self.rowcounter += 1