pd.get_dummies use code example
Example 1: how to get dummies in a dataframe pandas
df = pd.get_dummies(df, columns=['type'])
Example 2: pd.get_dummies
>>> s = pd.Series(list('abca'))
>>> pd.get_dummies(s)
a b c
0 1 0 0
1 0 1 0
2 0 0 1
3 1 0 0
Example 3: pandas.get_dummies
>>> pd.get_dummies(pd.Series(list('abcaa')), drop_first=True)
b c
0 0 0
1 1 0
2 0 1
3 0 0
4 0 0
Example 4: get dummies pandas
>>> pd.get_dummies(pd.Series(list('abc')), dtype=float)
a b c
0 1.0 0.0 0.0
1 0.0 1.0 0.0
2 0.0 0.0 1.0