-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Respect errors="ignore" during extension astype #35979
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
BUG: Respect errors="ignore" during extension astype #35979
Conversation
# TODO: Should we try/except this astype? | ||
values = self.values.astype(dtype) | ||
try: | ||
values = self.values.astype(dtype) |
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.
instead of this
add in this keyword to the EA astype
it's a little more code (as likely you need to refactor into an _astype method
but better i think
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.
I can add this, although it becomes a lot more code. I was able to pull a tiny bit into a helper function, but mostly each method seems to have its own idiosyncrasies that makes it hard to abstract away details. This became quite messy so let me know if I should revert and maybe leave as a follow-up enhancement.
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.
hmm, Changing the signature on the base extension array is an api change. I'm not so sure if this is a good idea since this only fixes pandas EAs and third party EAs that have overridden astype will need to update their code to support this.
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.
It seems too large of a change for a bug fix, went ahead and reverted
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.
ok fine on the change for backport (ex some comments), but can you create an issue to add this keyword to the EA signature?
@@ -565,3 +566,18 @@ def test_astype_empty_dtype_dict(self): | |||
result = df.astype(dict()) | |||
tm.assert_frame_equal(result, df) | |||
assert result is not df | |||
|
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.
do we have tests for these same types for errors='raise' (the default) and errors='coerce'?
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.
I don't think so for all, can add those here
[ | ||
Series(["x", "y", "z"], dtype="string"), | ||
Series(["x", "y", "z"], dtype="category"), | ||
Series(3 * [Timestamp("2020-01-01")]), |
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.
this needs a tz to be an EA
thanks @dsaxton |
@meeseeksdev backport 1.1.x |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff