plydata.cat_tools.cat_zip

plydata.cat_tools.cat_zip(*args, sep=':', keep_empty=False)[source]

Create a new categorical (zip style) combined from two or more

Parameters
*argstuple

Categoricals to be concatenated.

sepstr (default: ':')

Separator for the combined categories.

keep_emptybool (default: False)

If True, include all combinations of categories even those without observations.

Examples

>>> c1 = pd.Categorical(list('aba'))
>>> c2 = pd.Categorical(list('122'))
>>> cat_zip(c1, c2)
['a:1', 'b:2', 'a:2']
Categories (3, object): ['a:1', 'a:2', 'b:2']
>>> cat_zip(c1, c2, keep_empty=True)
['a:1', 'b:2', 'a:2']
Categories (4, object): ['a:1', 'a:2', 'b:1', 'b:2']