Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Pandas mod 0 should not give 0 #3590
Comments
|
div by 0 using the |
|
This is a dtype issue (these ops need conversion to float before interacting) Floats are fine
|
|
figured as much. kinda weird since one usually thinks about modulus as Z mod (another integer). also i can imagine a modulo for object blocks...string interp and such. @tavistmorph don't know if u know but numpy operates this way too, e.g., |
jreback
referenced
this issue
May 14, 2013
Merged
BUG: Fix integer modulo and division to make integer and float dtypes work similarly for invalid values #3600
jreback
closed this
in #3600
May 14, 2013
This was referenced Jun 26, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
darindillon commentedMay 13, 2013
In python:
3 % 0
is undefined and returns "ZeroDivisionError: integer division or modulo by zero"
But in pandas 0.11, that gives 0. I believe that is incorrect. It ought to give NaN or Inf
p = pandas.DataFrame({ 'first' : [3,4,5,8], 'second' : [0,0,0,3] })
p['mod'] = p['first'] % p['second']
p