Move dummy coding related functions from reshape/reshape into separate file
State: closed

Moves `get_dummies` into separate file `reshape/dummy_coding.py`.

- [x] Potential precursor PR to [`from_dummies`](https://github.com/pandas-dev/pandas/pull/41902#discussion_r772035162)
- [x] Passes atomic options tests
- [x] Passes linting tests
- [ ] Whatsnew entry

With `from_dummies` being added, it seems clearer to have a separate file for dummy coding related transformations - as suggested [here](https://github.com/pandas-dev/pandas/pull/41902#discussion_r772035162)

## To Discuss:
1. Separate file or not?
2. Opinions on the name `reshape/dummy_coding.py`?






Labels:
name: Refactor
description: Internal refactoring of code

Comments:
> Opinions on the name reshape/dummy_coding.py?

Maybe `encoding.py` to make it more generic?
> > Opinions on the name reshape/dummy_coding.py?
> 
> Maybe `encoding.py` to make it more generic?

Good idea, given that `from_dummies` will be added to this file as well - do you think the name `encoding.py` implies that the file holds the functions to decode the encodings (In the sense of "all encoding related stuff")?
> > > Opinions on the name reshape/dummy_coding.py?
> > 
> > 
> > Maybe `encoding.py` to make it more generic?
> 
> Good idea, given that `from_dummies` will be added to this file as well - do you think the name `encoding.py` implies that the file holds the functions to decode the encodings (In the sense of "all encoding related stuff")?

Yeah that's what I was thinking
> > > > Opinions on the name reshape/dummy_coding.py?
> > > 
> > > 
> > > Maybe `encoding.py` to make it more generic?
> > 
> > 
> > Good idea, given that `from_dummies` will be added to this file as well - do you think the name `encoding.py` implies that the file holds the functions to decode the encodings (In the sense of "all encoding related stuff")?
> 
> Yeah that's what I was thinking

I like this name and applied changes accordingly
> pandas/core/reshape/encoding.py:236: error: Incompatible types in assignment (expression has type "ndarray[Any, dtype[signedinteger[Any]]]", variable has type "Index")  [assignment]
pandas/core/reshape/encoding.py:246: error: Incompatible types in assignment (expression has type "ndarray[Any, dtype[Any]]", variable has type "Index")  [assignment]

are failing in the typing checks.
> > pandas/core/reshape/encoding.py:236: error: Incompatible types in assignment (expression has type "ndarray[Any, dtype[signedinteger[Any]]]", variable has type "Index")  [assignment]
> > pandas/core/reshape/encoding.py:246: error: Incompatible types in assignment (expression has type "ndarray[Any, dtype[Any]]", variable has type "Index")  [assignment]
> 
> are failing in the typing checks.

Jep, currently investigating this because for some reason I do not get that mypy error on my end - I have merged everything from `upstream/main` and updated the environment but I do not get any errors on `pandas/core/reshape/encoding.py`.
sorry you need to merge upstream/master again
> sorry you need to merge upstream/master again

Oh true, I was a little bit overhasty - but I hope mypy should be happy now.
Hello @pckSF! 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 2022-01-28 15:46:02 UTC
Okay looks like I made the CI even less happy with the last commit - I will sort it out this afternoon
> Okay looks like I made the CI even less happy with the last commit - I will sort it out this afternoon

The problem was that I missed some changes in `get_dummies` on `main` due to the entire function being the diff -> things broke. Should work again.
thanks @pckSF