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: numexpr / ops with boolean and conversion #7192

Closed
jreback opened this issue May 21, 2014 · 5 comments · Fixed by #7201
Closed

BUG: numexpr / ops with boolean and conversion #7192

jreback opened this issue May 21, 2014 · 5 comments · Fixed by #7201
Labels
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented May 21, 2014

these cases should give the same results. Somehow the ops order is being reversed or something with numexpr.

numpy 1.8.1, numexpr 2.4, pandas 0.14rc1
Can be worked around like:

In [39]: df = DataFrame(dict(A=np.random.randn(25000)))

In [40]: df.iloc[0:5] = np.nan

In [41]: (1-np.isnan(df)).iloc[0:25]
Out[41]: 
       A
0      0
1      0
2      0
3      0
4      0
5     -1
6     -1
7     -1
8     -1
9     -1
10    -1
11    -1
12    -1
13    -1
14    -1
15    -1
16    -1
17    -1
18    -1
19    -1
20    -1
21    -1
22    -1
23    -1
24    -1
25    -1
In [43]: df = DataFrame(dict(A=np.random.randn(25)))

In [44]: df.iloc[0:5] = np.nan

In [45]: (1-np.isnan(df)).iloc[0:25] 
Out[45]: 
    A
0   0
1   0
2   0
3   0
4   0
5   1
6   1
7   1
8   1
9   1
10  1
11  1
12  1
13  1
14  1
15  1
16  1
17  1
18  1
19  1
20  1
21  1
22  1
23  1
24  1
@jreback jreback added this to the 0.14.0 milestone May 21, 2014
@jreback jreback added the Bug label May 21, 2014
@jreback
Copy link
Contributor Author

jreback commented May 21, 2014

@cpcloud can you have a look.

@cpcloud
Copy link
Member

cpcloud commented May 21, 2014

How are these different? I can't see it.

@cpcloud
Copy link
Member

cpcloud commented May 21, 2014

Or are they not and that's the point

@jreback
Copy link
Contributor Author

jreback commented May 21, 2014

they are not, that's the point.

I think it has to do with numexpr and reversing bool ops (e.g. 1-np.nan(df) is evaluated as -np.nan(df) + 1 but in bool land that's not exactly the same (with numpy 1.8.1), I was running 1.7.2 before today....

you know those pandas devs wanted to test things out :)

@cpcloud
Copy link
Member

cpcloud commented May 21, 2014

Haha yep ok. I can take a look. I did make some changes there recently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants