-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
API: convert_objects, xref #11116, instead of warning, raise a ValueError #11133
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
…e a ValueError on old-style input - raise a ValueError for df.convert_objects('coerce') - raise a ValueError for df.convert_objects(convert_dates='coerce') (and convert_numeric,convert_timedelta)
cc AmbroseKeith |
I am not really in favor of this, as this really completely breaks people's code. Another option would be to not do any mapping of the old keyword arguments to the new ones. So leave the old keywords with deprecation warnings but their original behaviour, and the new keywords with the new behaviour. |
it's not the deprecation mappings that are a problem. it's that the coerce conversion by definition is forced. using it on s frame is just not a good idea at all. in prior versions it worked because it was really never a forced conversion. users code was simply wrong and should break I don't see any way around this nor should their be this is a loud break showing that what you were doing was wrong I suppose s better error message would help |
Yes, the fact that previously the conversion was not really 'forced' (as if it only converted if at least one could be converted), and now it is 'forced', this is what it is making a breaking change. Peoples code was not wrong, they were just using the function how it worked. Not doing the mapping of the old to the new keyword arguments would be a way to introduce the new behaviour (under the new kwargs) without breaking people's code (but of course, the old behaviour should still be supported in the code base in this case, which could make it more complex) I agree that this PR is in fact (in some cases) better than current master, as it raises an error notifying the user he/she should look at it, instead of just changing the result and breaking possible further processing. |
I don't see any reason to support old code like that |
Actually, what you are doing here is partly the same as I am saying: not doing the mapping of old to new kwargs (for the 'coerce' case). But the question is then what to do with the old kwargs: raising an error (this PR), or keeping the old behaviour but deprecating (allowing a more smooth transition). |
@jreback I don't say that is the better or easy approach, but the reason to do this is pretty clear: keep current user code working with 0.17.0 and giving them some time to adapt. |
Further, not doing the mapping would also allow us to further clean up some inconsistencies in the current API (which would otherwise be more breaking changes):
|
as I said I think we could give a better error message (kind of like instructions on how his changed) I'll put that up a bit later but this is a pretty narrow case - breaking is sometimes necessary |
I think that we should just change this whole approach - this is too error prone let's deprecate this entire function - not adding anything (so I guess revert to the prior behavior) - or just outright raise an error add eg same signature as that way the pattern is that the user needs to apply this to individual columns - |
another option is to make a new method and leave |
I agree with this. Better practice is to use
or
so the the minimal conversions is used (or an error is raised).
I think this is probably the right approach, plus adding |
@bashtage you want to take a crack at this?
|
@bashtage are you going to be able to address this? |
+1 to adding a I would not add a new |
I can get to it this week. IMO the old behavior of I think there are two ways forward:
In principle adding |
@bashtage thanks!
Yes this will break code, but it will loudly do it and I think only a very very small subset of users will experience this. We cannot cleanly do this as the fundamental behavior is changed. I suppose could revert to the original behavior, but simplest/easiest from this point is just raise. |
Agree on On |
ok, let's rollback the entire and add @bashtage change the documentation to advertise |
I have been working on the following:
One question: where should |
@bashtage awesome!
prob should reorg this at some point, though that is purely internal. |
closing in favor of #11173 |
Restores the v0.16 behavior of convert_objects and moves the new version of _convert Adds to_numeric for directly converting numeric data closes pandas-dev#11116 closes pandas-dev#11133
closes #11116
This is a lot more noisy that the current impl. It pretty much raises on the old-style input if it had
coerce
in it. This is correct as the actual behavior ofcoerce
has changed (in that it now it much more strict).errror on old-style input