Skip to content

Commit ba5f438

Browse files
committed
arrays/period: allow parsing of PeriodDtype columns from read_csv
Fixes: #26934 Signed-off-by: Antonio Gutierrez <[email protected]>
1 parent 269d368 commit ba5f438

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

doc/source/whatsnew/v0.25.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,7 @@ ExtensionArray
11861186
- :meth:`Series.count` miscounts NA values in ExtensionArrays (:issue:`26835`)
11871187
- Added ``Series.__array_ufunc__`` to better handle NumPy ufuncs applied to Series backed by extension arrays (:issue:`23293`).
11881188
- Keyword argument ``deep`` has been removed from :meth:`ExtensionArray.copy` (:issue:`27083`)
1189+
- Allow parsing of `PeriodDType` columns when using `read_csv()` (:issue:`26934`)
11891190
11901191
Other
11911192
^^^^^

pandas/core/arrays/period.py

+4
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ def _from_sequence(
253253
ordinals = libperiod.extract_ordinals(periods, freq)
254254
return cls(ordinals, freq=freq)
255255

256+
@classmethod
257+
def _from_sequence_of_strings(cls, strings, dtype=None, copy=False):
258+
return cls._from_sequence(strings, dtype, copy)
259+
256260
@classmethod
257261
def _from_datetime64(cls, data, freq, tz=None):
258262
"""

pandas/tests/extension/test_period.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,4 @@ class TestPrinting(BasePeriodTests, base.BasePrintingTests):
158158
class TestParsing(BasePeriodTests, base.BaseParsingTests):
159159
@pytest.mark.parametrize("engine", ["c", "python"])
160160
def test_EA_types(self, engine, data):
161-
expected_msg = r".*must implement _from_sequence_of_strings.*"
162-
with pytest.raises(NotImplementedError, match=expected_msg):
163-
super().test_EA_types(engine, data)
161+
super().test_EA_types(engine, data)

0 commit comments

Comments
 (0)