diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index 56bf394729773..46c8126f65fec 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -6,7 +6,7 @@ import warnings from pandas._libs import tslib, lib, tslibs -from pandas._libs.tslibs import iNaT, OutOfBoundsDatetime +from pandas._libs.tslibs import iNaT, OutOfBoundsDatetime, Period from pandas.compat import string_types, text_type, PY3 from .common import (ensure_object, is_bool, is_integer, is_float, is_complex, is_datetimetz, is_categorical_dtype, @@ -164,6 +164,12 @@ def trans(x): # noqa result = to_datetime(result).tz_localize('utc') result = result.tz_convert(dtype.tz) + elif dtype.type == Period: + # TODO(DatetimeArray): merge with previous elif + from pandas.core.arrays import PeriodArray + + return PeriodArray(result, freq=dtype.freq) + except Exception: pass diff --git a/pandas/tests/frame/test_combine_concat.py b/pandas/tests/frame/test_combine_concat.py index 2803db4f496a5..3b8d6e6c55ed1 100644 --- a/pandas/tests/frame/test_combine_concat.py +++ b/pandas/tests/frame/test_combine_concat.py @@ -759,7 +759,6 @@ def test_combine_first_timedelta(self): tm.assert_frame_equal(res, exp) assert res['TD'].dtype == 'timedelta64[ns]' - @pytest.mark.xfail(reason="GH-23079", strict=True) def test_combine_first_period(self): data1 = pd.PeriodIndex(['2011-01', 'NaT', '2011-03', '2011-04'], freq='M')