-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
added negative value support in pct_changes of generic.py #56627
added negative value support in pct_changes of generic.py #56627
Conversation
Thanks for the PR. Few points:
|
@asishm-wk I am not able to figure out the issue with the failing check |
The error comes from mypy - if you click on the failed build.
Looks like you removed the type ignore comment when you made the changes (needs to be there in both the if and else statements). |
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.
tests should likely go in pandas/tests/series/methods/test_pct_change.py
and see if you can use an existing test and parametrize the new argument.
pandas/core/generic.py
Outdated
@@ -12145,7 +12146,10 @@ def pct_change( | |||
|
|||
shifted = data.shift(periods=periods, freq=freq, axis=axis, **kwargs) | |||
# Unsupported left operand type for / ("Self") | |||
rs = data / shifted - 1 # type: ignore[operator] | |||
if use_absolute_value: | |||
rs = rs = (data - shifted) / abs(shifted) # type: ignore[operator] |
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.
rs = rs = (data - shifted) / abs(shifted) # type: ignore[operator] | |
rs = (data - shifted) / abs(shifted) # type: ignore[operator] |
pandas/tests/dtypes/test_generic.py
Outdated
@@ -1,3 +1,4 @@ | |||
import random |
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.
is the import and setting the seed below required?
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.
will check and remove if not required
I appreciate the PR but I am not sure it is worth expanding the API for this. |
Thanks for the PR but it is a bit too early to craft a solution to the issue as it's still being actively discussed. Going to close but we can reopen if it has more acceptance from the core developers |
closes #56618