Bug in DataFrame.drop_duplicates for empty DataFrame throws error
- [x] closes #20516
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22394?src=pr&el=h1) Report
> Merging [#22394](https://codecov.io/gh/pandas-dev/pandas/pull/22394?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/b5d81cfe43eeccfc3641aa9578097f726da9ce9d?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/22394/graphs/tree.svg?token=eZ4WkYLtcO&width=650&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/22394?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #22394      +/-   ##
==========================================
- Coverage   92.05%   92.04%   -0.01%     
==========================================
  Files         169      169              
  Lines       50709    50744      +35     
==========================================
+ Hits        46679    46708      +29     
- Misses       4030     4036       +6
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.45% <100%> (-0.01%)` | :arrow_down: |
| #single | `42.24% <0%> (-0.02%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/22394?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/22394/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.2% <100%> (-0.05%)` | :arrow_down: |
| [pandas/util/\_depr\_module.py](https://codecov.io/gh/pandas-dev/pandas/pull/22394/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvX2RlcHJfbW9kdWxlLnB5) | `65.11% <0%> (-2.33%)` | :arrow_down: |
| [pandas/core/reshape/pivot.py](https://codecov.io/gh/pandas-dev/pandas/pull/22394/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzaGFwZS9waXZvdC5weQ==) | `96.55% <0%> (-0.63%)` | :arrow_down: |
| [pandas/core/arrays/integer.py](https://codecov.io/gh/pandas-dev/pandas/pull/22394/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2ludGVnZXIucHk=) | `94.55% <0%> (-0.12%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/22394/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `85.75% <0%> (-0.11%)` | :arrow_down: |
| [pandas/core/reshape/merge.py](https://codecov.io/gh/pandas-dev/pandas/pull/22394/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzaGFwZS9tZXJnZS5weQ==) | `94.15% <0%> (-0.01%)` | :arrow_down: |
| [pandas/core/groupby/grouper.py](https://codecov.io/gh/pandas-dev/pandas/pull/22394/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9ncm91cGVyLnB5) | `98.16% <0%> (-0.01%)` | :arrow_down: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/22394/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `96.44% <0%> (-0.01%)` | :arrow_down: |
| [pandas/io/parsers.py](https://codecov.io/gh/pandas-dev/pandas/pull/22394/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3BhcnNlcnMucHk=) | `95.48% <0%> (ø)` | :arrow_up: |
| ... and [7 more](https://codecov.io/gh/pandas-dev/pandas/pull/22394/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22394?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/22394?src=pr&el=footer). Last update [b5d81cf...fc61899](https://codecov.io/gh/pandas-dev/pandas/pull/22394?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
 Test assert failed due to the following issue: #22409. Posted the details regarding this issue. Will try to update on it if I have time. @jreback @WillAyd @datapythonista  Should I just not include the test for columns until the #22409 is closed (as it will constantly tell that the shape is different due to column info is not there) or put this PR on hold until the above issue is closed? See note for the referenced issue but I don't think that is related (?). As @jreback mentioned you should parametrize the test case you have created. If so it will help more easily identify which if any case is failing @WillAyd Yes, I did parameterize the issue as @jreback mentioned, and while others are fine, the problem arose from this test:
```
    expected = DataFrame(columns=['A', 'B', 'C'])
    result = expected.drop_duplicates()
    tm.assert_frame_equal(result, expected)
```

current method for `DataFrame.drop_duplicates` follows this logic:
```
    duplicated = self.duplicated(subset, keep=keep)

    if inplace:
        inds, = (-duplicated).nonzero()
        new_data = self._data.take(inds)
        self._update_inplace(new_data)
    else:
        return self[-duplicated]
```
Since we are dealing with an empty ``DataFrame``,  the duplicated should be returning an empty ``Series`` as there exists no value to iterate over.

current assert_frame_equal checks for the shapes and column comparison within the code, as such:
```
    if left.shape != right.shape:
        raise_assert_detail(obj,
                            'DataFrame shape mismatch',
                            '{shape!r}'.format(shape=left.shape),
                            '{shape!r}'.format(shape=right.shape))
```
and
```
    assert_index_equal(left.columns, right.columns, exact=check_column_type,
                       check_names=check_names,
                       check_less_precise=check_less_precise,
                       check_exact=check_exact,
                       check_categorical=check_categorical,
                       obj='{obj}.columns'.format(obj=obj))
```

Considering that when selecting in `df[pd.Series()]` manner, column infos are by design not carrying over and thus fail the test, which spots different shape and index from the one the expected and result of the below test:

```
    expected = DataFrame(columns=['A', 'B', 'C'])
    result = expected.drop_duplicates()
    tm.assert_frame_equal(result, expected)
```

If this is the expected behavior, I think we can consider the fact and change the above snippet to following:

```
    df = DataFrame(columns=['A', 'B', 'C'])
    result = df.drop_duplicates()
    expected = DataFrame(columns=[]) # Since the column infos are not carrying over
    tm.assert_frame_equal(result, expected)
```
 Hello @HyunTruth! Thanks for updating the PR.





Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on August 22, 2018 at 13:38 Hours UTC lgtm. @datapythonista merge when satisfied. Thanks @HyunTruth  @jreback @datapythonista @WillAyd Thank you all