Handle duplicate column names in select_dtypes and get_dummies
State: closed

Functions `select_dtypes` and `get_dummies` previously failed on DataFrames with duplicate column names and had strange behavior as shown below. This PR fixes that strange behavior.

Previous behavior:

```python
In [6]: df
Out[6]: 
  col1 col1
0    1    a
1    2    b

In [7]: df.select_dtypes(include=['int'])
Out[7]: 
Empty DataFrame
Columns: []
Index: [0, 1]

In [8]: pd.get_dummies(df)
Out[8]: 
   col1_('c', 'o', 'l', '1')  col1_('c', 'o', 'l', '1')
0                          1                          1
1                          1                          1
```

New behavior:

```python
In [6]: df
Out[6]: 
  col1 col1
0    1    a
1    2    b

In [7]: df.select_dtypes(include=['int'])
Out[7]: 
   col1
0     1
1     2

In [8]: pd.get_dummies(df)
Out[8]: 
   col1  col1_a  col1_b
0     1       1       0
1     2       0       1
```

- [x] closes #20848
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry


Labels:
name: Bug
name: Reshaping
description: Concat, Merge/Join, Stack/Unstack, Explode

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20839?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@e8e6e89`). [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/20839/graphs/tree.svg?height=150&width=650&token=eZ4WkYLtcO&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/20839?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##             master   #20839   +/-   ##
=========================================
  Coverage          ?   91.81%           
=========================================
  Files             ?      153           
  Lines             ?    49481           
  Branches          ?        0           
=========================================
  Hits              ?    45432           
  Misses            ?     4049           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.21% <100%> (?)` | |
| #single | `41.85% <0%> (?)` | |

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

------

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

does this have an open issue?
Hi @jreback, thanks for the quick turn-around. I've addressed the comments above, opened an issue and linked it above.

Let me know what you think.
Thanks @jreback. I resolved comments and added the whatsnew note.
Rebased on master so checks pass now @jreback.
thanks @kunalgosar nice patch!