Skip to content

Conversation

@natmokval
Copy link
Contributor

xref #52064

Added a test with freq=1MS to increase coverage of shift. The reason: existing tests don't cover a case if the index of a DataFrame is a DatetimeIndex.

@natmokval natmokval marked this pull request as ready for review July 20, 2023 18:44
@natmokval
Copy link
Contributor Author

@MarcoGorelli, , could you please take a look at this pr?

@MarcoGorelli MarcoGorelli added Datetime Datetime data dtype Needs Tests Unit test(s) needed to prevent regressions labels Jul 21, 2023
@MarcoGorelli MarcoGorelli added this to the 2.1 milestone Jul 21, 2023
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

Always happy to see coverage increase, thanks!

@MarcoGorelli MarcoGorelli merged commit 2907b20 into pandas-dev:main Jul 21, 2023
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Datetime Datetime data dtype Needs Tests Unit test(s) needed to prevent regressions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants