Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for NaT when performing dt.to_period #24921

Merged
merged 3 commits into from
Jan 26, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pandas/tests/series/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,13 @@ def test_end_time_timevalues(self, input_vals):
result = s.dt.end_time
expected = s.apply(lambda x: x.end_time)
tm.assert_series_equal(result, expected)

@pytest.mark.parametrize('input_vals, expected', [
(Series(['2001'], dtype='datetime64[ns]'),
Series(['2001'], dtype='period[D]')),
(Series(['NaT'], dtype='datetime64[ns]'),
Series(['NaT'], dtype='period[D]'))
alexander-ponomaroff marked this conversation as resolved.
Show resolved Hide resolved
])
def test_to_period(self, input_vals, expected):
result = input_vals.dt.to_period('D')
alexander-ponomaroff marked this conversation as resolved.
Show resolved Hide resolved
tm.assert_series_equal(result, expected)