BUG: Fix bug when using df.query with "str.contains()"
State: closed

- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

Fixes bug in on line 588 of `pandas/core/computation/expr.py`: `AttributeError: 'dict' object has no attribute 'append'`

Also addresses the specific example in #22172

Example:
```python
import pandas as pd
df = pd.DataFrame([["I", "XYZ"], ["IJ", None]], columns=['A', 'B'])
df.query("B.str.contains('Z', na=False)", engine="python")
```

```
Traceback (most recent call last):
  File "./test_query.py", line 12, in <module>
    result = df.query("B.str.contains('Z', na=False)", engine="python")
  File "./lib/python3.6/site-packages/pandas/core/frame.py", line 2847, in query
    res = self.eval(expr, **kwargs)
  File "./lib/python3.6/site-packages/pandas/core/frame.py", line 2962, in eval
    return _eval(expr, inplace=inplace, **kwargs)
  File "./lib/python3.6/site-packages/pandas/core/computation/eval.py", line 291, in eval
    truediv=truediv)
  File "./lib/python3.6/site-packages/pandas/core/computation/expr.py", line 739, in __init__
    self.terms = self.parse()
  File "./lib/python3.6/site-packages/pandas/core/computation/expr.py", line 756, in parse
    return self._visitor.visit(self.expr)
  File "./lib/python3.6/site-packages/pandas/core/computation/expr.py", line 321, in visit
    return visitor(node, **kwargs)
  File "./lib/python3.6/site-packages/pandas/core/computation/expr.py", line 327, in visit_Module
    return self.visit(expr, **kwargs)
  File "./lib/python3.6/site-packages/pandas/core/computation/expr.py", line 321, in visit
    return visitor(node, **kwargs)
  File "./lib/python3.6/site-packages/pandas/core/computation/expr.py", line 330, in visit_Expr
    return self.visit(node.value, **kwargs)
  File "./lib/python3.6/site-packages/pandas/core/computation/expr.py", line 321, in visit
    return visitor(node, **kwargs)
  File "./lib/python3.6/site-packages/pandas/core/computation/expr.py", line 588, in visit_Call_35
    kwargs.append(ast.keyword(
AttributeError: 'dict' object has no attribute 'append'
```


Labels:
name: Indexing
description: Related to indexing on series/frames, not to indexes themselves
name: DataFrame
description: DataFrame data structure

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25813?src=pr&el=h1) Report
> Merging [#25813](https://codecov.io/gh/pandas-dev/pandas/pull/25813?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/fbe25233345b750031911f0d4b0845fa115c4432?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/25813/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/25813?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #25813      +/-   ##
==========================================
+ Coverage   91.27%   91.27%   +<.01%     
==========================================
  Files         173      173              
  Lines       53002    53002              
==========================================
+ Hits        48375    48378       +3     
+ Misses       4627     4624       -3
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.85% <100%> (+0.01%)` | :arrow_up: |
| #single | `41.77% <0%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25813?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/computation/expr.py](https://codecov.io/gh/pandas-dev/pandas/pull/25813/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tcHV0YXRpb24vZXhwci5weQ==) | `89.27% <100%> (+0.74%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25813?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25813?src=pr&el=footer). Last update [fbe2523...64004bc](https://codecov.io/gh/pandas-dev/pandas/pull/25813?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25813?src=pr&el=h1) Report
> Merging [#25813](https://codecov.io/gh/pandas-dev/pandas/pull/25813?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/5a150694731d2ecce670cca65760c472338a04fa?src=pr&el=desc) will **decrease** coverage by `0.62%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/25813/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/25813?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #25813      +/-   ##
==========================================
- Coverage   91.89%   91.27%   -0.63%     
==========================================
  Files         175      173       -2     
  Lines       52509    53002     +493     
==========================================
+ Hits        48255    48378     +123     
- Misses       4254     4624     +370
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.85% <100%> (-0.6%)` | :arrow_down: |
| #single | `41.77% <0%> (+0.89%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25813?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/computation/expr.py](https://codecov.io/gh/pandas-dev/pandas/pull/25813/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tcHV0YXRpb24vZXhwci5weQ==) | `89.27% <100%> (-7.43%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/25813/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-62.5%)` | :arrow_down: |
| [pandas/compat/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/25813/diff?src=pr&el=tree#diff-cGFuZGFzL2NvbXBhdC9fX2luaXRfXy5weQ==) | `58.03% <0%> (-19.47%)` | :arrow_down: |
| [pandas/io/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/25813/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2NvbW1vbi5weQ==) | `72.86% <0%> (-18.97%)` | :arrow_down: |
| [pandas/io/excel/\_util.py](https://codecov.io/gh/pandas-dev/pandas/pull/25813/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2V4Y2VsL191dGlsLnB5) | `78.82% <0%> (-8.68%)` | :arrow_down: |
| [pandas/compat/chainmap.py](https://codecov.io/gh/pandas-dev/pandas/pull/25813/diff?src=pr&el=tree#diff-cGFuZGFzL2NvbXBhdC9jaGFpbm1hcC5weQ==) | `61.9% <0%> (-4.77%)` | :arrow_down: |
| [pandas/core/groupby/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/25813/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9jYXRlZ29yaWNhbC5weQ==) | `95.45% <0%> (-4.55%)` | :arrow_down: |
| [pandas/core/dtypes/cast.py](https://codecov.io/gh/pandas-dev/pandas/pull/25813/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Nhc3QucHk=) | `88.16% <0%> (-3.2%)` | :arrow_down: |
| [pandas/io/s3.py](https://codecov.io/gh/pandas-dev/pandas/pull/25813/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3MzLnB5) | `86.36% <0%> (-3.12%)` | :arrow_down: |
| ... and [115 more](https://codecov.io/gh/pandas-dev/pandas/pull/25813/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25813?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25813?src=pr&el=footer). Last update [5a15069...223e034](https://codecov.io/gh/pandas-dev/pandas/pull/25813?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@dtpc can you merge master and address comments?
can you merge master and update
@pandas-dev/pandas-core if someone wants to finish up
this PR is superseded by #26426