Issue 1:
Code Sample, a copy-pastable example if possible

import pandas as pd

df = pd.DataFrame({
'Foo64': [1.2, 2.4, 7.24],
})

df['Foo32'] = df['Foo64'].astype('float32')

df.eval('-1 + Foo64') # Works
df.eval('-1 + Foo32') # Throws Exception

Traceback (most recent call last):
File "C:\Users\vmuriart\Desktop\bug_eval.py", line 10, in <module>
df.eval('-1 + Foo32') # Throws Exception
File "C:\Anaconda\lib\site-packages\pandas\core\frame.py", line 2186, in eval
return _eval(expr, inplace=inplace, **kwargs)
File "C:\Anaconda\lib\site-packages\pandas\core\computation\eval.py", line 262, in eval
truediv=truediv)
File "C:\Anaconda\lib\site-packages\pandas\core\computation\expr.py", line 727, in __init__
self.terms = self.parse()
File "C:\Anaconda\lib\site-packages\pandas\core\computation\expr.py", line 744, in parse
return self._visitor.visit(self.expr)
File "C:\Anaconda\lib\site-packages\pandas\core\computation\expr.py", line 313, in visit
return visitor(node, **kwargs)
File "C:\Anaconda\lib\site-packages\pandas\core\computation\expr.py", line 319, in visit_Module
return self.visit(expr, **kwargs)
File "C:\Anaconda\lib\site-packages\pandas\core\computation\expr.py", line 313, in visit
return visitor(node, **kwargs)
File "C:\Anaconda\lib\site-packages\pandas\core\computation\expr.py", line 322, in visit_Expr
return self.visit(node.value, **kwargs)
File "C:\Anaconda\lib\site-packages\pandas\core\computation\expr.py", line 313, in visit
return visitor(node, **kwargs)
File "C:\Anaconda\lib\site-packages\pandas\core\computation\expr.py", line 417, in visit_BinOp
left, right = self._maybe_downcast_constants(left, right)
File "C:\Anaconda\lib\site-packages\pandas\core\computation\expr.py", line 365, in _maybe_downcast_constants
name = self.env.add_tmp(np.float32(left.value))
AttributeError: 'UnaryOp' object has no attribute 'value'

Problem description

df.eval(...) operations fail if one of the columns involved is of type float32 and some unary operations are involved. In the example above df.eval('-1 + Foo32') failed, but df.eval('-Foo32') will succeed, and df.eval('-1*Foo32') will also fail.

Originally I tested fixing this by just adding self.value = operand.value to the UnaryOp object, before I realized that this issue only affects float32 objects. I haven't looked to see where the code branches off to cause this misbehavior.

This was tested and reproduced on both 0.20.3 and 0.22.0

Expected Output

No exception thrown.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None

python: 3.6.3.final.0

python-bits: 64

OS: Windows

OS-release: 10

machine: AMD64

processor: Intel64 Family 6 Model 79 Stepping 1, GenuineIntel

byteorder: little

LC_ALL: None

LANG: None

LOCALE: None.None

pandas: 0.22.0

pytest: 3.2.1

pip: 9.0.1

setuptools: 36.5.0.post20170921

Cython: 0.26.1

numpy: 1.12.1

scipy: 0.19.1

pyarrow: 0.7.1

xarray: None

IPython: 6.1.0

sphinx: 1.6.3

patsy: 0.4.1

dateutil: 2.6.1

pytz: 2017.2

blosc: None

bottleneck: 1.2.1

tables: 3.4.2

numexpr: 2.6.2

feather: None

matplotlib: 2.1.0

openpyxl: 2.4.8

xlrd: 1.1.0

xlwt: 1.3.0

xlsxwriter: 1.0.2

lxml: 4.1.0

bs4: 4.6.0

html5lib: 0.999999999

sqlalchemy: 1.1.13

pymysql: None

psycopg2: None

jinja2: 2.9.6

s3fs: None

fastparquet: None

pandas_gbq: None

pandas_datareader: None

Issue 2:
Code Sample, a copy-pastable example if possible

def test_unary():
df = pd.DataFrame({'x': np.array([0.11, 0], dtype=np.float32)})
res = df.eval('(x > 0.1) | (x < -0.1)')
assert np.array_equal(res, np.array([True, False])), res

Problem description

This is related to #11235.

on python 3.6, pandas 20.1, this raises an error the traceback ends with:

File ".../envs/py3/lib/python3.6/site-packages/pandas/core/computation/expr.py", line 370, in _maybe_downcast_constants
name = self.env.add_tmp(np.float32(right.value))
AttributeError: 'UnaryOp' object has no attribute 'value'

In that case the right is -(0.1)

INSTALLED VERSIONS
------------------
commit: None
python: 3.6.1.final.0
python-bits: 64
OS: Linux
OS-release: 4.8.0-49-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.20.1

pytest: None

pip: 9.0.1

setuptools: 27.2.0

Cython: 0.25.2

numpy: 1.12.1

scipy: 0.19.0

xarray: None

IPython: 6.0.0

sphinx: None

patsy: None

dateutil: 2.6.0

pytz: 2017.2

blosc: None

bottleneck: None

tables: None

numexpr: None

feather: None

matplotlib: 2.0.2

openpyxl: None

xlrd: None

xlwt: None

xlsxwriter: None

lxml: None

bs4: None

html5lib: None

sqlalchemy: None

pymysql: None

psycopg2: None

jinja2: None

s3fs: None

pandas_gbq: None

pandas_datareader: None

Another example:

>>> df = pd.DataFrame({'x':[1,2,3,4,5]})
>>> df.eval('x.shift(-1)')