Skip to content

df.query bug giving RuntimeWarning: divide by zero encountered in log10 in align.py", line 98, in _align_core ordm = np.log10(abs(reindexer_size - term_axis_size)) #13135

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

Closed
aliabbasjp opened this issue May 11, 2016 · 3 comments
Labels
Bug Numeric Operations Arithmetic, Comparison, and Logical operations
Milestone

Comments

@aliabbasjp
Copy link

aliabbasjp commented May 11, 2016

Getting the following bug:

RuntimeWarning: divide by zero encountered in log10
C:\Users\Nick\Anaconda3\lib\site-packages\pandas\computation\align.py:98:
ordm = np.log10(abs(reindexer_size - term_axis_size))
while running query().

dtypes:

CGI int64
SITEID int32
LONGITUDE float64
LATITUDE float32
dtype: object
Query:

towerData = towerData.query('CGI != 0')

once you get this runtime warning it just halts everything and you have to restart the program.

This bug happens only in multithreaded calls to query function. I am using the concurrent.futures module for the same.

runs fine for non threaded application

@sinhrks
Copy link
Member

sinhrks commented May 11, 2016

Thanks for the report. Do you have minimal copy-pastable example?

@jreback jreback added the Numeric Operations Arithmetic, Comparison, and Logical operations label May 11, 2016
@rkern
Copy link
Contributor

rkern commented May 11, 2016

Note: I'll be avoiding that warning explicitly in my fix for #13109. The numpy error state is thread-local IIRC, so the current fire-and-forget np.seterr(all='ignore') probably only takes effect in the main thread. Why the OP's program halts after the warning, I don't know.

@grove80904
Copy link

grove80904 commented Jul 29, 2016

I'm having a similar issue even without threading. See example code below.

`
import pandas as pd
import numpy as np
df = pd.DataFrame.from_items([('A', [1, 2, 3, 4, 5]),
('B', [14, 15, 16, 17, 18]),
('C', list(np.random.randn(5)))])
df.set_index(['A', 'B'], inplace = True)
df.query('15 <= B <= 17')

C:\Anaconda3\lib\site-packages\pandas\computation\align.py:98:
RuntimeWarning: divide by zero encountered in log10
ordm = np.log10(abs(reindexer_size - term_axis_size))
Out[1]:
C
A B
2 15 -0.852411
3 16 -0.665470
4 17 0.132162
`

Windows 7 64 bit
Spyder 3.0.0.dev0
Python 3.5.2
Pandas 0.18.1
Numpy 1.11.1

@jreback jreback added this to the 0.19.0 milestone Aug 17, 2016
@jreback jreback added the Bug label Aug 17, 2016
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.

5 participants