TYP: Overload series/drop_dupicates
State: closed

- [ ] closes part of https://github.com/MarcoGorelli/pyladies-sprint-April-2021/issues/29
- [ ] tests added / passed
- [ ] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing.html#code-standards) for how to run them
- [ ] whatsnew entry


Labels:
name: Typing
description: type annotations, mypy/pyright type checking

Comments:
Nice one @olgarithms , thanks!

Could you also include a comment in which you show the output of something like https://github.com/pandas-dev/pandas/pull/40860#issuecomment-817144849 ?
Hmm, the output doesn't seem right but I am not very sure why..

```
# t.py

import pandas as pd

inplace: bool

reveal_type(pd.DataFrame([1,2,3]).drop_duplicates())
reveal_type(pd.DataFrame([1,2,3]).drop_duplicates(keep="last"))
reveal_type(pd.DataFrame([1,2,3]).drop_duplicates(inplace=True))
reveal_type(pd.DataFrame([1,2,3]).drop_duplicates(keep="last", inplace=True))
reveal_type(pd.DataFrame([1,2,3]).drop_duplicates(inplace=False))
reveal_type(pd.DataFrame([1,2,3]).drop_duplicates(keep="last", inplace=False))
reveal_type(pd.DataFrame([1,2,3]).drop_duplicates(inplace=inplace))
reveal_type(pd.DataFrame([1,2,3]).drop_duplicates(keep="last", inplace=inplace))
```

```
$ mypy t.py
t.py:7: note: Revealed type is 'Union[pandas.core.frame.DataFrame, None]'
t.py:8: note: Revealed type is 'Union[pandas.core.frame.DataFrame, None]'
t.py:9: note: Revealed type is 'Union[pandas.core.frame.DataFrame, None]'
t.py:10: note: Revealed type is 'Union[pandas.core.frame.DataFrame, None]'
t.py:11: note: Revealed type is 'Union[pandas.core.frame.DataFrame, None]'
t.py:12: note: Revealed type is 'Union[pandas.core.frame.DataFrame, None]'
t.py:13: note: Revealed type is 'Union[pandas.core.frame.DataFrame, None]'
t.py:14: note: Revealed type is 'Union[pandas.core.frame.DataFrame, None]'
```
Perhaps try running `mypy pandas` again, and then `mypy t.py`?
Oops, my bad, I was using `drop_duplicates` from `DataFrame`.

The correct test:
```
# t.py

import pandas

inplace: bool

reveal_type(pandas.Series([1,2,3]).drop_duplicates())
reveal_type(pandas.Series([1,2,3]).drop_duplicates(keep="last"))
reveal_type(pandas.Series([1,2,3]).drop_duplicates(inplace=True))
reveal_type(pandas.Series([1,2,3]).drop_duplicates(keep="last", inplace=True))
reveal_type(pandas.Series([1,2,3]).drop_duplicates(inplace=False))
reveal_type(pandas.Series([1,2,3]).drop_duplicates(keep="last", inplace=False))
reveal_type(pandas.Series([1,2,3]).drop_duplicates(inplace=inplace))
reveal_type(pandas.Series([1,2,3]).drop_duplicates(keep="last", inplace=inplace))
```
```
$ mypy t.py
t.py:7: note: Revealed type is 'pandas.core.series.Series'
t.py:8: note: Revealed type is 'pandas.core.series.Series'
t.py:9: note: Revealed type is 'None'
t.py:10: note: Revealed type is 'None'
t.py:11: note: Revealed type is 'pandas.core.series.Series'
t.py:12: note: Revealed type is 'pandas.core.series.Series'
t.py:13: note: Revealed type is 'Union[pandas.core.series.Series, None]'
t.py:14: note: Revealed type is 'Union[pandas.core.series.Series, None]'
```
Nice work, thanks @olgarithms !

> Oops, my bad, I was using drop_duplicates from DataFrame.

:laughing: no worries - though seeing as you're familiar with how to do this now, if you wanted to do the overloads `DataFrame.drop_duplicates`, that would be welcome! Else I'll open it up as an issue for others to take
Sure, I can take that one too :)