Skip to content

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

Merged
merged 3 commits into from
Nov 23, 2021
Merged

BUG: DataFrame.diff(np_int_obj) #44577

merged 3 commits into from
Nov 23, 2021

Conversation

jbrockmendel
Copy link
Member

Copy link
Member

@phofl phofl left a comment

Choose a reason for hiding this comment

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

lgtm

@lithomas1 lithomas1 added the Reduction Operations sum, mean, min, max, etc. label Nov 23, 2021
@lithomas1 lithomas1 added this to the 1.4 milestone Nov 23, 2021
@@ -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):
Copy link
Member

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]

Copy link
Member Author

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

Copy link
Member

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):
Copy link
Contributor

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

Copy link
Member Author

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

Copy link
Contributor

Choose a reason for hiding this comment

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

kk add to list :->

@jreback jreback merged commit 8c17c1b into pandas-dev:master Nov 23, 2021
@jbrockmendel jbrockmendel deleted the bugs branch November 23, 2021 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reduction Operations sum, mean, min, max, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: diff method raises ValueError when it's called with np.int64
4 participants