From bcfaeed1120ffcb3d176f749f12a6996e0c80c86 Mon Sep 17 00:00:00 2001 From: Antonio Gutierrez Date: Sat, 13 Jul 2019 16:42:24 +0200 Subject: [PATCH] arrays/period: allow parsing of PeriodDtype columns from read_csv Fixes: https://github.com/pandas-dev/pandas/issues/26934 Signed-off-by: Antonio Gutierrez --- pandas/core/arrays/period.py | 4 ++++ pandas/tests/extension/test_period.py | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index 8291cb70affcd8..b0336c46d19539 100644 --- a/pandas/core/arrays/period.py +++ b/pandas/core/arrays/period.py @@ -253,6 +253,10 @@ def _from_sequence( ordinals = libperiod.extract_ordinals(periods, freq) return cls(ordinals, freq=freq) + @classmethod + def _from_sequence_of_strings(cls, strings, dtype=None, copy=False): + return cls._from_sequence(strings, dtype, copy) + @classmethod def _from_datetime64(cls, data, freq, tz=None): """ diff --git a/pandas/tests/extension/test_period.py b/pandas/tests/extension/test_period.py index 8a500e1be766e6..c439b8b5ed3194 100644 --- a/pandas/tests/extension/test_period.py +++ b/pandas/tests/extension/test_period.py @@ -158,6 +158,4 @@ class TestPrinting(BasePeriodTests, base.BasePrintingTests): class TestParsing(BasePeriodTests, base.BaseParsingTests): @pytest.mark.parametrize("engine", ["c", "python"]) def test_EA_types(self, engine, data): - expected_msg = r".*must implement _from_sequence_of_strings.*" - with pytest.raises(NotImplementedError, match=expected_msg): - super().test_EA_types(engine, data) + super().test_EA_types(engine, data)