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

numexpr 2.3.1 error with pandas 0.13.1 #6762

Closed
bluefir opened this issue Apr 1, 2014 · 24 comments · Fixed by #6803
Closed

numexpr 2.3.1 error with pandas 0.13.1 #6762

bluefir opened this issue Apr 1, 2014 · 24 comments · Fixed by #6803
Labels
Bug Compat pandas objects compatability with Numpy or Python functions Numeric Operations Arithmetic, Comparison, and Logical operations Testing pandas testing functions or related to the test suite
Milestone

Comments

@bluefir
Copy link

bluefir commented Apr 1, 2014

I just installed numexpr 2.3.1 with pandas 0.13.1 and got the following error:

File "C:\Python27\lib\site-packages\pandas\core\ops.py", line 496, in wrapper
arr = na_op(lvalues, rvalues)
File "C:\Python27\lib\site-packages\pandas\core\ops.py", line 443, in na_op
raise_on_error=True, *_eval_kwargs)
File "C:\Python27\lib\site-packages\pandas\computation\expressions.py", line 176, in evaluate
*_eval_kwargs)
File "C:\Python27\lib\site-packages\pandas\computation\expressions.py", line 104, in _evaluate_numexpr
*_eval_kwargs)
File "C:\Python27\lib\site-packages\numexpr\necompiler.py", line 738, in evaluate
NumExpr(ex, signature, *context)
File "C:\Python27\lib\site-packages\numexpr\necompiler.py", line 554, in NumExpr
precompile(ex, signature, context)
File "C:\Python27\lib\site-packages\numexpr\necompiler.py", line 498, in precompile
ast = typeCompileAst(ast)
File "C:\Python27\lib\site-packages\numexpr\necompiler.py", line 163, in typeCompileAst
% (ast.value + '
' + retsig+basesig))
NotImplementedError: couldn't find matching opcode for 'mul_bbb'

@jreback
Copy link
Contributor

jreback commented Apr 1, 2014

and what exactly are you doing when it gives that error?

@bluefir
Copy link
Author

bluefir commented Apr 1, 2014

Good point.

n_nonzero_returns_idc = np.sum(portfolio_data[field_return_daily_idc].notnull() *
                               (portfolio_data[field_return_daily_idc] != 0.0))

@cpcloud
Copy link
Member

cpcloud commented Apr 1, 2014

why not just do & instead?

@jreback
Copy link
Contributor

jreback commented Apr 1, 2014

can't use booleans in numexpr with multiply; need to astype(int) if you reall y want to do that

as @cpcloud says, why are you not using &?

@cpcloud
Copy link
Member

cpcloud commented Apr 1, 2014

still ... should this fall back onto python/bottleneck ops?

@bluefir
Copy link
Author

bluefir commented Apr 1, 2014

& worked - had to change it everywhere. cpcloud is right: & is better than *. I started using & instead of * when I realized that. May be it's a good reason to correct those things. Still, has numexpr become more hard ass about things like that?

@jreback
Copy link
Contributor

jreback commented Apr 1, 2014

maybe not catching the NotImplementedError?

and not testing with 2.3.1...hmmm will fix that...

@jreback
Copy link
Contributor

jreback commented Apr 1, 2014

I take that back...we ARE testing on window 2.3.1.....guess don't have a test for that particular case.....

@cpcloud when you have a chance?

@cpcloud
Copy link
Member

cpcloud commented Apr 1, 2014

i don't think numexpr has ever supported arithmetic ops on bool dtype arrays. not sure why this is throwing from pandas tho ... @jreback sure

@jreback jreback added this to the 0.14.0 milestone Apr 1, 2014
@bluefir
Copy link
Author

bluefir commented Apr 1, 2014

used to work with numexpr 2.0.1 and pandas 0.12

@jreback
Copy link
Contributor

jreback commented Apr 1, 2014

I agree....should just catch and revert to python

@bluefir what numpy are you using?

@jreback
Copy link
Contributor

jreback commented Apr 1, 2014

looks like 2.1 changed this (to a warning then later deprecated)....see here: https://github.com/pydata/numexpr/blob/master/RELEASE_NOTES.rst

@cpcloud
Copy link
Member

cpcloud commented Apr 1, 2014

oh didn't know they were on gh awesom

@cpcloud
Copy link
Member

cpcloud commented Apr 1, 2014

now we can add opcodes and datetime timedelta support hurrah!!!

@bluefir
Copy link
Author

bluefir commented Apr 1, 2014

numpy 1.8.1

@bluefir
Copy link
Author

bluefir commented Apr 1, 2014

Ok, just to intercept here. Are you guys saying there is a faster way of doing what I am trying to do?

@jreback
Copy link
Contributor

jreback commented Apr 1, 2014

looks like you are trying to index something else but keep shape?

df.where(cond1 & cond2)

or just select

df[cond1 & cond2]

to just get the indexed data

@cpcloud
Copy link
Member

cpcloud commented Apr 1, 2014

could also do np.sum(df[the_slice_or_index].fillna(0.0) != 0)

@bluefir
Copy link
Author

bluefir commented Apr 1, 2014

I just want to calculate the number of values in a column that are not null and not equal to zero.

@jreback
Copy link
Contributor

jreback commented Apr 1, 2014

s[s!=0].count()

@bluefir
Copy link
Author

bluefir commented Apr 1, 2014

Ha! Indeed. Thanks!

@cpcloud
Copy link
Member

cpcloud commented Apr 2, 2014

@jreback should the arith bool ops return the same thing as combine? combine actually does each operation "manually" then puts the result in an array of the same type as the lhs and rhs ... which makes truediv different for numpy arrays vs. combine ... just not sure what direction the consistency should go np or pandas

@cpcloud
Copy link
Member

cpcloud commented Apr 2, 2014

dividing bools is weird and is an edge case so it's not THAT important i just need to pick one

@jreback
Copy link
Contributor

jreback commented Apr 2, 2014

I think you just raise on all bool dtypes that are not boolean types (e.g. &,|,~|-). no reason for numexpr to support * which is the only meaningful one (+ and /) don't make sense at all and subtraction is just negation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Compat pandas objects compatability with Numpy or Python functions Numeric Operations Arithmetic, Comparison, and Logical operations Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants