#### Code Sample, a copy-pastable example if possible
# encoding: UTF-8
import pandas as pd
import numpy as np
data1 = {"x": np.random.randint(2, size=6000),
"y":np.random.randint(2, size=6000),
}
df1 = pd.DataFrame(data1)
data2 = {"x": np.random.randint(2, size=6000),
"y":np.random.randint(2, size=6000),
}
df2 = pd.DataFrame(data2)
df = df1&df2
print df
#### Expected Output
Print the dataframe fill with 0 or 1
#### output of ``pd.show_versions()``
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.11.final.0
python-bits: 32
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 69 Stepping 1, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
pandas: 0.18.1
nose: None
pip: None
setuptools: None
Cython: None
numpy: 1.11.1
scipy: 0.16.1
statsmodels: None
xarray: None
IPython: 4.1.2
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.6.1
blosc: None
bottleneck: None
tables: None
numexpr: 2.5.2
matplotlib: 1.4.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
boto: None
pandas_datareader: None
None
Comment From: jreback
In the future, pls show the actual error message.
In [14]: pd.options.display.max_rows=4
In [15]: pandas.computation.expressions.set_use_numexpr(False)
In [16]: df1&df2
Out[16]:
x y
0 0 1
1 0 1
... .. ..
5998 0 0
5999 0 1
[6000 rows x 2 columns]
In [17]: pandas.computation.expressions.set_use_numexpr(True)
In [18]: df1&df2
NotImplementedError: couldn't find matching opcode for 'and_bll'
The issue is an incompat between numexpr
and numpy
. The logical operator &
is not supported on integer types in numexpr
but is in numpy
. These are normally operated with boolean dtypes.
This particular operation is, however, equivalent to the *
operator.
I suppose we could either:
1) raise a more informative message explaining this
2) Just sub *
for &
for integer dtypes; not a good sub for |
though.
3) cast logical ops a-priori.
Comment From: jreback
@fj11 as an aside, 32-bit windows is pretty much unsupported (and it has many limitations). use the 64-bit version.
Comment From: fj11
@jreback thanks for your comments.
Comment From: jbrockmendel
This now works, closing.