Skip to content

TST: add a test with freq=1MS to increase coverage of shift #54211

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

Merged
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
9 changes: 9 additions & 0 deletions pandas/tests/frame/methods/test_shift.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,3 +656,12 @@ def test_shift_axis1_many_periods(self):

shifted2 = df.shift(-6, axis=1, fill_value=None)
tm.assert_frame_equal(shifted2, expected)

def test_shift_with_offsets_freq(self):
df = DataFrame({"x": [1, 2, 3]}, index=date_range("2000", periods=3))
shifted = df.shift(freq="1MS")
expected = DataFrame(
{"x": [1, 2, 3]},
index=date_range(start="02/01/2000", end="02/01/2000", periods=3),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine here, but in the future, I'd suggest using 2000-02-01 format, it's less ambiguous, whereas 02/01/2000 means different things in different parts of the world

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I will use 2000-02-01 format.

)
tm.assert_frame_equal(shifted, expected)