Skip to content
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: Series.float divided by Series.interger (with 0's) #7785

Closed
xdliao opened this issue Jul 18, 2014 · 3 comments · Fixed by #7786
Closed

BUG: Series.float divided by Series.interger (with 0's) #7785

xdliao opened this issue Jul 18, 2014 · 3 comments · Fixed by #7786
Labels
Bug Numeric Operations Arithmetic, Comparison, and Logical operations
Milestone

Comments

@xdliao
Copy link

xdliao commented Jul 18, 2014

problem when denominator is interger type and has 0 element

no such problem with pandas <= 0.13.1

print pd.version
print np.version

testdata=pd.DataFrame({'TL': (1,0), 'PI': (-0.01,-0.02)})
print "--- direct pd.Series division (wrong) : \n", (testdata.PI)/testdata.TL
print "--- np.where filtered (still wrong!!): ",np.where(testdata.TL>0.001,testdata.PI/testdata.TL,0 )
print "--- direct pd.Series division (OK for float type) : \n", testdata.PI/(testdata.TL.astype(float))
print "--- values division (correct)", testdata.PI.values/testdata.TL.values

-------------- Output ---------
0.14.0
1.7.1
--- direct pd.Series division (wrong) :
0 -inf
1 -inf
dtype: float64
--- np.where filtered (still wrong!!): [-inf 0.]
--- direct pd.Series division (OK for float type) :
0 -0.010000
1 -inf
dtype: float64
--- values division (correct) [-0.01 -inf]

@jreback
Copy link
Contributor

jreback commented Jul 18, 2014

hmm, this does look like its doing the wrong thing. care to do a pull-request to fix ?

@jreback jreback added this to the 0.15.0 milestone Jul 18, 2014
@xdliao
Copy link
Author

xdliao commented Jul 18, 2014

I am new to development and probably will take too long

@jreback jreback changed the title pandas Series division bug BUG: Series.float divided by Series.interger (with 0's) Jul 18, 2014
@jreback
Copy link
Contributor

jreback commented Jul 18, 2014

fixed in #7786. Bug in that sign<0 & mask should have been (sign<0) & mask, with boolean numpy arrays (this didn't show up before because its done solely when filling with -np.inf (e.g. the sign of the inf).

thanks for the report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants