Skip to content

TST: Add failing tests for minute rounding #21265

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

Closed
wants to merge 1 commit into from
Closed
Changes from all 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
19 changes: 19 additions & 0 deletions pandas/tests/scalar/timestamp/test_unary_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,25 @@ def test_ceil_floor_edge(self, test_input, rounder, freq, expected):
expected = Timestamp(expected)
assert result == expected

@pytest.mark.parametrize('test_input, freq, expected', [
('2018-01-01 00:02:00', '2T', '2018-01-01 00:02:00'),
('2018-01-01 00:04:00', '4T', '2018-01-01 00:04:00'),
('2018-01-01 00:15:00', '15T', '2018-01-01 00:15:00'),
('2018-01-01 00:20:00', '20T', '2018-01-01 00:20:00'),
])
def test_round_minute_freq(self, test_input, freq, expected):
# ensure timestamps that shouldn't round don't
# GH#21262
dt = Timestamp(test_input)
expected = Timestamp(expected)

result_ceil = dt.ceil(freq)
assert result_ceil == expected
result_floor = dt.floor(freq)
assert result_floor == expected
result_round = dt.round(freq)
assert result_round == expected

def test_ceil(self):
dt = Timestamp('20130101 09:10:11')
result = dt.ceil('D')
Expand Down