ENH: let get_dummies take a DataFrame
State: closed

Closes https://github.com/pydata/pandas/issues/8133

Thoughts? I encode every column with `object` dtype. You can control the ones that get encoded with `categorical_variables`. The encoded columns are `concat`ed to the columns that don't need encoding.

`prefix` and `prefix_sep` can be passed as a string, list, or dict mapping column names to strs.

``` python
In [1]: from pandas import *

In [2]: df = DataFrame({'A': ['a', 'b', 'a'], 'B': ['b', 'a', 'c'],
                        'C': [1, 2, 3]})

In [3]: df
Out[3]: 
   A  B  C
0  a  b  1
1  b  a  2
2  a  c  3

In [4]: get_dummies(df)
Out[4]: 
   C  A_a  A_b  B_a  B_b  B_c
0  1    1    0    0    1    0
1  2    0    1    1    0    0
2  3    1    0    0    0    1

In [5]: get_dummies(df, prefix=['from_A', 'from_B'])
Out[5]: 
   C  from_A_a  from_A_b  from_B_a  from_B_b  from_B_c
0  1         1         0         0         1         0
1  2         0         1         1         0         0
2  3         1         0         0         0         1

In [6]: get_dummies(df, prefix={"A": 'from_A', "B": 'from_B'})
Out[6]: 
   C  from_A_a  from_A_b  from_B_a  from_B_b  from_B_c
0  1         1         0         0         1         0
1  2         0         1         1         0         0
2  3         1         0         0         0         1

In [7]: get_dummies(df, prefix_sep='.')
Out[7]: 
   C  A.a  A.b  B.a  B.b  B.c
0  1    1    0    0    1    0
1  2    0    1    1    0    0
2  3    1    0    0    0    1

In [8]: get_dummies(df, prefix_sep='.', categorical_variables=['A'])
Out[8]: 
   B  C  A.a  A.b
0  b  1    1    0
1  a  2    0    1
2  c  3    1    0
```


Labels:
name: Reshaping
description: Concat, Merge/Join, Stack/Unstack, Explode
name: API Design
name: Categorical
description: Categorical Data Type

Comments:
you are inconsistent with cat_variables and categorical_variables
I would eliminate convert_dummies (or prfix with _)

can u show the output in the top of this pr (of the examples)

Yeah I chose to spell out `cat_variables`. I figured it would be ok since `covert_dummies` wasn't used. I can change to the shortened version to be consistent if need be.

I'll put a deprecation warning on `covert_dummies` saying to just use get dummies instead. We should be able to remove it entirely pretty soon.

I didn't mean to change `covert_dummies` at all. I'll change that keyword argument back to how it was.

Added convert_dummies to https://github.com/pydata/pandas/issues/6581 We'll remove in 0.16 I think.

I'm updating that issue to keep a log of when things need to be removed by release.

I don't this we should have prefix_sep
we don't do that anywhere else (you could create another issue for that however to add it to multiple functions and/or have an set_option for it which might be better)

Made an issue about the `prefix_sep` https://github.com/pydata/pandas/issues/8141

Some feedback:
- Now that we have a 'category' dtype, you should also check for that (so not only 'object' dtype)
- good to deprecate/remove `convert_dummies`
- I am not too fond on the `categorical_variables` keyword .. It is really long, what do other people think of the `include/exclude` as what you mentioned in the original issue (https://github.com/pydata/pandas/issues/955#issuecomment-53664656), or simply `columns`?

I would use `columns` rather than `category_variables` 

Thanks.
- Changed `categorical_variables` -> `columns`
- Encoding object and categorical dtypes by default
- Fixed typos
- Change Deprecation to FutureWarning and caught that in the tests.

See anything else that needs fixing?

Looks good to me. 
@hayd I think you did some work previously on get_dummies?

Andy added the NaN handling. I didn't have this in an example, but it behaves pretty much the same except you can have multiple NaN columns in the output, one for each input with a NaN. 

+1 on this and also on depreciating `convert_dummies`.

seems good extension! I like your NaN handling but maybe be worth adding test with dummy_na=False (I can't see one)?

_Note: I previously added `str.get_dummies` but, relooking at that, that's slightly different._

Thanks. Added a test with NaNs, but `dummy_na=False`. I'll merge later today if there aren't any objects.

Going to merge now with the `prefix_nan` vs. `prefix_NaN` issue unchanged since that would (potentially) break code.