From 6d7df83f4e8ed1ea394a2bce55b7307cad5d3cad Mon Sep 17 00:00:00 2001 From: Brock Date: Tue, 24 Nov 2020 10:04:55 -0800 Subject: [PATCH 1/2] CLN: dont mix Int64Index into PeriodIndex --- pandas/core/indexes/period.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index e25119162368f..0f9a0052c18d0 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -65,7 +65,7 @@ def _new_PeriodIndex(cls, **d): wrap=True, ) @inherit_names(["is_leap_year", "_format_native_types"], PeriodArray) -class PeriodIndex(DatetimeIndexOpsMixin, Int64Index): +class PeriodIndex(DatetimeIndexOpsMixin): """ Immutable ndarray holding ordinal values indicating regular periods in time. @@ -436,8 +436,7 @@ def join(self, other, how="left", level=None, return_indexers=False, sort=False) ) # _assert_can_do_setop ensures we have matching dtype - result = Int64Index.join( - self, + result = super().join( other, how=how, level=level, From 3bb361df17292cc642d3d2fa48ff02adceb48c8d Mon Sep 17 00:00:00 2001 From: Brock Date: Tue, 24 Nov 2020 13:09:28 -0800 Subject: [PATCH 2/2] fixup isinstance check --- pandas/io/pytables.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 21f7899f24b51..d7ee4acc2e670 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -44,6 +44,7 @@ is_list_like, is_string_dtype, is_timedelta64_dtype, + needs_i8_conversion, ) from pandas.core.dtypes.missing import array_equivalent @@ -4771,7 +4772,7 @@ def _convert_index(name: str, index: Index, encoding: str, errors: str) -> Index kind = _dtype_to_kind(dtype_name) atom = DataIndexableCol._get_atom(converted) - if isinstance(index, Int64Index): + if isinstance(index, Int64Index) or needs_i8_conversion(index.dtype): # Includes Int64Index, RangeIndex, DatetimeIndex, TimedeltaIndex, PeriodIndex, # in which case "kind" is "integer", "integer", "datetime64", # "timedelta64", and "integer", respectively.