Skip to content

Commit

Permalink
arrays/period: allow parsing of PeriodDtype columns from read_csv
Browse files Browse the repository at this point in the history
Fixes: #26934

Signed-off-by: Antonio Gutierrez <chibby0ne@gmail.com>
  • Loading branch information
chibby0ne committed Jul 13, 2019
1 parent 269d368 commit bcfaeed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pandas/core/arrays/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
4 changes: 1 addition & 3 deletions pandas/tests/extension/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit bcfaeed

Please sign in to comment.