Skip to content

use is_integer in df.insert #53194

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 7 commits into from
May 14, 2023

Conversation

auderson
Copy link
Contributor

@@ -4800,7 +4800,7 @@ def insert(
if not allow_duplicates and column in self.columns:
# Should this be a different kind of error??
raise ValueError(f"cannot insert {column}, already exists")
if not isinstance(loc, int):
if not is_integer(loc):
Copy link
Member

Choose a reason for hiding this comment

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

Could you convert non stdlib ints to satisfy typing checks?

@@ -110,3 +110,8 @@ def test_insert_frame(self):
)
with pytest.raises(ValueError, match=msg):
df.insert(1, "newcol", df)

def test_insert_int64_loc(self):
Copy link
Member

Choose a reason for hiding this comment

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

Could you add the GH issue number?

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

Could you add a whatsnew note in v2.1.0.rst?

@mroeschke mroeschke added the Dtype Conversions Unexpected or buggy dtype conversions label May 12, 2023
@auderson
Copy link
Contributor Author

Which section of the whatsnew note should I add it to, Conversion?

@mroeschke
Copy link
Member

Which section of the whatsnew note should I add it to, Conversion?

Sure

@auderson
Copy link
Contributor Author

done

Which section of the whatsnew note should I add it to, Conversion?

Sure

Copy link
Contributor

@topper-123 topper-123 left a comment

Choose a reason for hiding this comment

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

LGTM.

@topper-123 topper-123 merged commit f80436d into pandas-dev:main May 14, 2023
@topper-123
Copy link
Contributor

Thanks, @auderson.

Rylie-W pushed a commit to Rylie-W/pandas that referenced this pull request May 19, 2023
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: df.insert can't accept int64 value
3 participants