Skip to content

Commit 5d84bc0

Browse files
TomAugspurgerjorisvandenbossche
authored andcommitted
BUG: Handle Period in combine (pandas-dev#23350)
1 parent 48782a8 commit 5d84bc0

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pandas/core/dtypes/cast.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import warnings
77

88
from pandas._libs import tslib, lib, tslibs
9-
from pandas._libs.tslibs import iNaT, OutOfBoundsDatetime
9+
from pandas._libs.tslibs import iNaT, OutOfBoundsDatetime, Period
1010
from pandas.compat import string_types, text_type, PY3
1111
from .common import (ensure_object, is_bool, is_integer, is_float,
1212
is_complex, is_datetimetz, is_categorical_dtype,
@@ -164,6 +164,12 @@ def trans(x): # noqa
164164
result = to_datetime(result).tz_localize('utc')
165165
result = result.tz_convert(dtype.tz)
166166

167+
elif dtype.type == Period:
168+
# TODO(DatetimeArray): merge with previous elif
169+
from pandas.core.arrays import PeriodArray
170+
171+
return PeriodArray(result, freq=dtype.freq)
172+
167173
except Exception:
168174
pass
169175

pandas/tests/frame/test_combine_concat.py

-1
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,6 @@ def test_combine_first_timedelta(self):
759759
tm.assert_frame_equal(res, exp)
760760
assert res['TD'].dtype == 'timedelta64[ns]'
761761

762-
@pytest.mark.xfail(reason="GH-23079", strict=True)
763762
def test_combine_first_period(self):
764763
data1 = pd.PeriodIndex(['2011-01', 'NaT', '2011-03',
765764
'2011-04'], freq='M')

0 commit comments

Comments
 (0)