from SO
.add_categories
should be able to take an Index
/ndarray, ATM it must be converted to a listIn [147]: s = pd.Categorical(list('aabbcd'))
In [148]: s2 = list('aabbcdefg')
In [149]: s
Out[149]:
[a, a, b, b, c, d]
Categories (4, object): [a, b, c, d]
In [150]: s.add_categories(s.categories.sym_diff(Index(s2)).tolist())
Out[150]:
[a, a, b, b, c, d]
Categories (7, object): [a, b, c, d, e, f, g]
I would ideally just like to say:
s.add_categories(s2, take_new=True)
(maybe not the best keyword, but something like this)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4