-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. kk add to list :-> |
||
# np.int64 is OK GH#44572 | ||
df = DataFrame(np.random.randn(2, 2)) | ||
res = df.diff(np.int64(1)) | ||
expected = df.diff(1) | ||
tm.assert_frame_equal(res, expected) | ||
|
||
def test_diff(self, datetime_frame): | ||
the_diff = datetime_frame.diff(1) | ||
|
||
|
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()):
.