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

Closed
xdliao opened this Issue Jul 18, 2014 · 3 comments

Comments

Projects
None yet
2 participants

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]

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 added this to the 0.15.0 milestone Jul 18, 2014

xdliao commented Jul 18, 2014

I am new to development and probably will take too long

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

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

jreback closed this in #7786 Jul 18, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment