-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fix issue with old-style usage in convert_objects #10602
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
lgtm |
I don't think this handles the case where you did two different types at the same time? Eg |
That case was wrong in 0.16 so I don't think it should be fixed. Coerce should mean one and only one type allowed. The only question is whether I should be setting the non-coerce string to False, or just pass them through. A different strategy would be to set any input that is coerce to |
An example with simultaneous numeric and dates, which already worked in 0.15. Was it a bug that it worked?
|
import datetime as dt
df = pd.DataFrame({'a':['1.','2010-01-01',dt.datetime.now()-dt.datetime.now()]}) Any of these either don't work or don't make sense:
The issue is there are was a a very specific order as to what happens, and once one has satisied some criteria, then the others weren't attempted. For example, in the final one, why is the result numeric? |
it only did the conversions (even soft conversions) if it had an You will warn if any of the above examples are passed, so that is ok! |
9a5728f
to
bf1d34e
Compare
@bashtage @jreback coming back to this:
Further, the default was previously to do date conversions. Now it is stated in the docs that the default is changed to do nothing. However, if I try on master, it seems that by default it does do numeric conversions:
So it seems that the |
@jorisvandenbossche The purpose of So this should not generally be necessary from a callers perspective for datetimes/timedeltas as we already have a well-defined way of doing this (e.g. How about adding a Downside is you cannot then say to pandas "just figure this out", by doing |
@bashtage can you update and respond to above comments. |
What was the decision? Make |
I think it would be ok to add |
The original new_values = some_fn(x)
# A step like this is missing
if not np.isnan(new_values).all():
values = new_values
# End missing
return values This isn't in master since my modified |
ok so their was an old bug which you fixed, but what are we missing with the new one that is necessary for back-compat? can you give an exmple |
The version currently in master has a different signature. In particular,
which always struck me an horribly ambiguous as to what you get - the returned type depends on the order of the code in the function, which seems like a fragile ("magic") design. This can't happen with the new one since
will raise since this is ambiguous. I suppose there are a few different options:
There is one final issue with |
Fix to temporary allow passing 'coerce' to variables closes pandas-dev#10601
bf1d34e
to
6ceb303
Compare
@bashtage I think that you have preserved back compat enough. I would add a warning box in the whatsnew and the docs saying if you are relying upon the 'magic' then you need to be forewarned. Separately I think we should go forward with |
I have a PR nearly ready for I'm all for not changing things, but I was under the impression that @jorisvandenbossche felt strongly about supporting the same arguments. |
If I am reading the above correctly, then the objection is that the following did work.
It seems to me that this is easily cause though and might as well raise on this. (e.g. you are seeing the deprecated args, you know that the user is trying to do). It may be that intercepting this via the decorator is a bit tricky though (as you are using the mapping; maybe preserving the args and then just warning as you see them is better)? |
@jorisvandenbossche comments? this lgtm |
BUG: Fix issue with old-style usage in convert_objects
merging. I think this is fine. |
Fix to temporary allow passing 'coerce' to variables
closes #10601