-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Change NDFrame.div()
to be truediv in Python 2.X
#5356
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
Comments
you don't think it would more consistent to break all truediv? (e.g. '/' as well). would be very consistent |
I would not be opposed that (we aren't doing anything special on an int column that gets an nan anyways) |
IIRC this is pretty triviall to implement (just flip a paramter ?), but need a v0.13 mention....should we defer to 0.14? |
It's incredibly trivial to implement. I'm skeptical that anyone would be
|
I don't see a problem with having consistent behavior between Python 2 and 3. I'm sure plenty of developers are importing division from |
Great, I'll put up a PR |
Now that we have all the arithmetic methods, there's no reason to keep it as before. Not having this means that operating on an int column with missing values switches operation result from floordiv to truediv.
@wesm You had, at one point, said that you would consider this. I believe this change would iron over a long-standing Python wart and make pandas easier to use:
Existing behavior (note how the future import doesn't affect div at all because it's defined in a separate file, but does affect division because Python will call
__truediv__
instead of__div__
):And missing values immediately causes this behavior to change (because coerces to float)
And this distinction is totally eliminated in Python 3:
Trivial to fix and, while slightly backwards incompatible, would mostly just make things simpler. We should still leave
a / b
to be dependent upon the future import.The text was updated successfully, but these errors were encountered: