6.8.2.1.6. statsmodels.sandbox.stats.contrast_tools.dummy_1d

statsmodels.sandbox.stats.contrast_tools.dummy_1d(x, varname=None)[source]

dummy variable for id integer groups

Returns:

dummy : ndarray, 2d

array of dummy variables, one column for each level of the category (full set)

labels : list of strings

labels for the columns, i.e. levels of each category

See also

statsmodels.tools.categorical

Notes

use tools.categorical instead for more more options

Examples

>>> x = np.array(['F', 'F', 'M', 'M', 'F', 'F', 'M', 'M', 'F', 'F', 'M', 'M'],
      dtype='|S1')
>>> dummy_1d(x, varname='gender')
(array([[1, 0],
       [1, 0],
       [0, 1],
       [0, 1],
       [1, 0],
       [1, 0],
       [0, 1],
       [0, 1],
       [1, 0],
       [1, 0],
       [0, 1],
       [0, 1]]), ['gender_F', 'gender_M'])