liwca.drop_category#
- liwca.drop_category(dx, categories)[source]#
Remove one or more categories from a dictionary.
Terms that no longer belong to any remaining category are dropped automatically.
- Parameters:
dx (
pandas.DataFrame) – A dictionary DataFrame as returned byread_dx.categories (
stror list ofstr) – Category name(s) to remove.
- Returns:
A new dictionary DataFrame without the specified categories.
- Return type:
- Raises:
KeyError – If any of the given category names are not present in dx.
Examples
>>> import liwca >>> dx = liwca.create_dx({"sports": ["baseball", "hockey"], "weather": ["rain*", "snow"]}) >>> liwca.drop_category(dx, "weather") Category sports DicTerm baseball 1 hockey 1