BUG: assignment to multiple columns when some column do not exist
State: closed

- [x] closes #13658
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

In particular, the following code now behaves correctly.

```python
import pandas as pd
df = pd.DataFrame({'a': [0, 1, 2], 'b': [3, 4, 5]})
df[['a', 'c']] = 1
print(df)
```
v0.22: error

master: column `'c'` is converted to index `-1`, which causes last column to be overwritten.
```
   a  b
0  1  1
1  1  1
2  1  1
```

After this PR:
```
   a  b  c
0  1  3  1
1  1  4  1
2  1  5  1
```

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

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

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

```diff
@@            Coverage Diff             @@
##           master   #26534      +/-   ##
==========================================
- Coverage   91.76%   91.76%   -0.01%     
==========================================
  Files         174      174              
  Lines       50629    50632       +3     
==========================================
- Hits        46462    46461       -1     
- Misses       4167     4171       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.3% <100%> (ø)` | :arrow_up: |
| #single | `41.68% <0%> (-0.09%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26534?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26534/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.01% <100%> (-0.12%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26534/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `78.94% <0%> (-10.53%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26534?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/26534?src=pr&el=footer). Last update [0a516c1...7bc1856](https://codecov.io/gh/pandas-dev/pandas/pull/26534?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/26534?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@24bd67e`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff            @@
##             master   #26534   +/-   ##
=========================================
  Coverage          ?   91.87%           
=========================================
  Files             ?      174           
  Lines             ?    50701           
  Branches          ?        0           
=========================================
  Hits              ?    46581           
  Misses            ?     4120           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.41% <100%> (?)` | |
| #single | `41.79% <57.69%> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26534?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26534/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97% <100%> (ø)` | |
| [pandas/core/indexing.py](https://codecov.io/gh/pandas-dev/pandas/pull/26534/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhpbmcucHk=) | `93.6% <100%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26534?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/26534?src=pr&el=footer). Last update [24bd67e...3054b6d](https://codecov.io/gh/pandas-dev/pandas/pull/26534?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Hello @howsiwei! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:









There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: 

##### Comment last updated at 2019-08-18 09:49:14 UTC
@jreback any feedback?
Hi, thanks for the feedback. I have updated to a much cleaner code.
@jreback what do you think about the current changes? Also do you have any idea why It's failing on Linux py37_np_dev?
@jreback I have moved my entire fix to earlier stage of setting as https://github.com/pandas-dev/pandas/pull/27604 remove `is_setter` which is required in my earlier approach. What do you think about it?
@howsiwei have been away for a while, can you merge master and i'll look again.
@howsiwei can you merge master and i'll have another look
closing as stale but @howsiwei ping if you'd like to pick this backup
@WillAyd I'll pick this back up in these few days.
Sounds good. I don't have the option to reopen though - did you delete the branch on GitHub? If so unfortunately might need to push a new PR 
I suspect it's because I rebase the branch on latest master.
I have created a new PR #29334.