-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: DataFrame.diff(np_int_obj) #44577
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
Conversation
jbrockmendel
commented
Nov 22, 2021
- closes BUG: diff method raises ValueError when it's called with np.int64 #44572
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
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.
lgtm
@@ -8612,7 +8612,7 @@ def melt( | |||
), | |||
) | |||
def diff(self, periods: int = 1, axis: Axis = 0) -> DataFrame: | |||
if not isinstance(periods, int): | |||
if not lib.is_integer(periods): |
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.
pandas/core/frame.py:8616: error: "int" has no attribute "is_integer" [attr-defined]
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.
that's pretty weird, looks like a mypy problem to 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.
My bad, this actually refers to the line below if not (is_float(periods) and periods.is_integer()):
.
@@ -17,6 +17,13 @@ def test_diff_requires_integer(self): | |||
with pytest.raises(ValueError, match="periods must be an integer"): | |||
df.diff(1.5) | |||
|
|||
def test_diff_allows_np_integer(self): |
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.
fine, could just parameterize the below one
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.
not wild about this as it is, but it looks like the next test could use a good splitting, after which combining might make more sense
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.
kk add to list :->