Skip to content

Commit

Permalink
BUG: Handle Period in combine (pandas-dev#23350)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAugspurger authored and Pingviinituutti committed Feb 28, 2019
1 parent 9d0a1d7 commit 3c00547
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 7 additions & 1 deletion pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion pandas/tests/frame/test_combine_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 3c00547

Please sign in to comment.