-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: .shift optionally takes multiple periods #54115
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
rhshadrach
merged 32 commits into
pandas-dev:main
from
jona-sassenhagen:jona/44424_shift
Jul 28, 2023
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
4e1a84e
init
jona-sassenhagen db9cd03
precommit
jona-sassenhagen 9def045
slightly update test
jona-sassenhagen b7ea297
Fix groupby API tests
jona-sassenhagen 299927a
mostly types, also exclude groupby
jona-sassenhagen 6cf632e
fix test
jona-sassenhagen 23d9142
mypy
jona-sassenhagen b78d7d6
fix docstring
jona-sassenhagen cabd28c
change how futurewarning is handled in the test
jona-sassenhagen 5017721
fix docstring
jona-sassenhagen 6f3ec9b
remove debug statement
jona-sassenhagen 8d085f3
address comments
jona-sassenhagen 6e66a19
refactor
jona-sassenhagen f7ea7a3
handle default
jona-sassenhagen f8e29d9
pylint
jona-sassenhagen e54ba33
Merge branch 'main' into jona/44424_shift
jona-sassenhagen 715c397
Merge branch 'main' into jona/44424_shift
jona-sassenhagen 21e8e70
merge conflicts and mypy
jona-sassenhagen 0e78963
split tests, remove checking for None default
jona-sassenhagen 2c602e2
Merge branch 'main' into jona/44424_shift
jona-sassenhagen d9bf54f
address comments
jona-sassenhagen 778b7e9
Merge branch 'main' into jona/44424_shift
jona-sassenhagen ad49861
Merge branch 'jona/44424_shift' of github.com:jona-sassenhagen/pandas…
jona-sassenhagen 28469db
mypy
jona-sassenhagen c8e5bad
mypy again
jona-sassenhagen cb4013d
Merge branch 'main' into jona/44424_shift
jona-sassenhagen 226fa6f
Merge branch 'main' into jona/44424_shift
jona-sassenhagen cb49cac
black
jona-sassenhagen 44b0866
address comments
jona-sassenhagen 5257292
Merge branch 'main' into jona/44424_shift
jona-sassenhagen eff4ed2
mypy
jona-sassenhagen 04d4513
Merge branch 'jona/44424_shift' of github.com:jona-sassenhagen/pandas…
jona-sassenhagen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary because Series.shift can now return a dataframe if there are multiple periods. Mypy complains at this line because it wants Series and not
Series | Dataframe
, but because there is only one lag, it's alwaysSeries
, so we can justcast
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could add type-overloads to handle this. Sometimes they can get gnarly (see e.g. concat), but I think this one should be relatively straight forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer not to if that's ok? There is no
Series.shift
to overload so I feel like it would be confusing to newcomers like me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you insist I will try!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise I think this is done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @rhshadrach , do you have time for another round/sign this off?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with opening an issue regarding this once it's merged for someone to followup on.