|
14 | 14 | from pandas.core.dtypes.common import is_bool, is_list_like, is_scalar
|
15 | 15 |
|
16 | 16 | import pandas as pd
|
17 |
| -from pandas import DataFrame, Series, date_range |
| 17 | +from pandas import DataFrame, Series, compat, date_range |
18 | 18 | from pandas.core.computation import pytables
|
19 | 19 | from pandas.core.computation.check import _NUMEXPR_VERSION
|
20 | 20 | from pandas.core.computation.engines import NumExprClobberingError, _engines
|
@@ -1267,7 +1267,10 @@ def test_assignment_column(self):
|
1267 | 1267 | msg = "left hand side of an assignment must be a single name"
|
1268 | 1268 | with pytest.raises(SyntaxError, match=msg):
|
1269 | 1269 | df.eval("d,c = a + b")
|
1270 |
| - msg = "can't assign to function call" |
| 1270 | + if compat.PY38: |
| 1271 | + msg = "cannot assign to function call" |
| 1272 | + else: |
| 1273 | + msg = "can't assign to function call" |
1271 | 1274 | with pytest.raises(SyntaxError, match=msg):
|
1272 | 1275 | df.eval('Timestamp("20131001") = a + b')
|
1273 | 1276 |
|
@@ -1967,6 +1970,26 @@ def test_bool_ops_fails_on_scalars(lhs, cmp, rhs, engine, parser):
|
1967 | 1970 | pd.eval(ex, engine=engine, parser=parser)
|
1968 | 1971 |
|
1969 | 1972 |
|
| 1973 | +@pytest.mark.parametrize( |
| 1974 | + "other", |
| 1975 | + [ |
| 1976 | + "'x'", |
| 1977 | + pytest.param( |
| 1978 | + "...", marks=pytest.mark.xfail(not compat.PY38, reason="GH-28116") |
| 1979 | + ), |
| 1980 | + ], |
| 1981 | +) |
| 1982 | +def test_equals_various(other): |
| 1983 | + df = DataFrame({"A": ["a", "b", "c"]}) |
| 1984 | + result = df.eval("A == {}".format(other)) |
| 1985 | + expected = Series([False, False, False], name="A") |
| 1986 | + if _USE_NUMEXPR: |
| 1987 | + # https://github.com/pandas-dev/pandas/issues/10239 |
| 1988 | + # lose name with numexpr engine. Remove when that's fixed. |
| 1989 | + expected.name = None |
| 1990 | + tm.assert_series_equal(result, expected) |
| 1991 | + |
| 1992 | + |
1970 | 1993 | def test_inf(engine, parser):
|
1971 | 1994 | s = "inf + 1"
|
1972 | 1995 | expected = np.inf
|
|
0 commit comments