ENH: get_dummies can accept value and na_value kw
State: closed

Closes #8028. It is still under work, but want to clarify a point. Currently it  works as:

```
s = pd.Series(['A', 'B', 'A', 'C'])
s
#0    A
#1    B
#2    A
#3    C
# dtype: object

pd.get_dummies(s)
#    A  B  C
#0  1  0  0
#1  0  1  0
#2  1  0  0
#3  0  0  1

pd.get_dummies(s, value='YES', na_value='NO')
#      A    B    C
#0  YES   NO   NO
#1   NO  YES   NO
#2  YES   NO   NO
#3   NO   NO  YES

pd.get_dummies(s, value={'A': 'X', 'B': 'Y', 'C': 'Z'})
#    A  B  C
#0  X  0  0
#1  0  Y  0
#2  X  0  0
#3  0  0  Z
```

And what I'm concerning is cases for list-likes. 

```
# This is natural and compat with replace, because the number of the hole will be the same number as list (one hole in each column).
pd.get_dummies(s, value=['A', 'B', 'A', 'C'])
#    A  B  C
#0  A  0  0
#1  0  B  0
#2  A  0  0
#3  0  0  C

# When we specify na_value and make it compat with replace, behavior should be:
pd.get_dummies(s, na_value=['A', 'B', 'A', 'C'])
#    A  B  C
0  1  A  B
1  A  1  C
2  1  A  B
3  A  C  1

# Or it needs different broadcasting rule?
pd.get_dummies(s, na_value=['A', 'B', 'A', 'C'])
#    A  B  C
#0  1  A  A
#1  B  1  B
#2  1  A  A
#3  C  C  1
```


Labels:
name: Enhancement
name: Reshaping
description: Concat, Merge/Join, Stack/Unstack, Explode
name: API Design

Comments:
ideally (and I think there is an issue about this) each of these columns are categoricals 

I would not support the list-like for value, not really necessary and confusing. The scalar/dict is ok though.

What I have in my mind is transforming transaction-like data. But agree it should be discussed separately to be consistent with `fill_na` and `replace`.

OK to raise `ValueError` against list/Series input for now?

```
From:
#ID Product  Price
# 0       A    100
# 1       B     50
# 2       C     10
# 3       A    100

To:
get_dummies(df['Product'], value=df['Price'])
#ID   A   B  C
# 0 100   0  0
# 1   0  50  0
# 2   0   0 10
# 3 100   0  0
```

@sinhrks Your last example, is that not a case for `pivot/pivot_table`? I don't know if it is needed `get_dummies` can handle this:

```
In [166]: df = pd.DataFrame({'ID':[0,1,2,3], 'Product':list('ABCA'), 'Price':[10
0, 50, 10, 100]})

In [167]: df
Out[167]:
   ID  Price Product
0   0    100       A
1   1     50       B
2   2     10       C
3   3    100       A

In [168]: df.pivot('ID', 'Product', 'Price').fillna(0)
Out[168]:
Product    A   B   C
ID
0        100   0   0
1          0  50   0
2          0   0  10
3        100   0   0
```

@jorisvandenbossche You're right. 

Updated to reject `list` and `Series`. 

I think we need a better name for `na_value`. From the name, I'd expect that to apply to missing values (e.g. NaN / None), just like the `dummy_na` parameter.

Possible alternatives:
- pos(itive)_value / neg(ative)_value
- present_value / absent_value

maybe others. I like present / absent, but that may not be great for non-native English speakers.

OK, will change keyword if there is any other suggestions.

Changed keywords to `pos_value` and `neg_value` based on the suggestion.

Just a question: is it that difficult to just do replace yourself:

```
In [5]: s = pd.Series(['A', 'B', 'A', 'C'])

In [6]: pd.get_dummies(s).replace({1:'YES', 0:'NO'})
Out[6]:
     A    B    C
0  YES   NO   NO
1   NO  YES   NO
2  YES   NO   NO
3   NO   NO  YES
```

I don't find `pd.get_dummies(s).replace({1:'YES', 0:'NO'})` that more verbose or complex than `pd.get_dummies(s, pos_value='YES', neg_value='NO')` (it is even shorter).

I ask the question, as this 'bloats' the API further, for something that is already possible in a straightforward way.

I think this needs some more discussion, pushing till 0.17.0

I agree with @jorisvandenbossche here. I think let's add an example using `.replace` to the doc-string (and maybe the cookbook).

Yes, let me close this once. Thanks for consideration. Will prepare a PR for a doc example.