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:
Returns:

A new dictionary DataFrame without the specified categories.

Return type:

pandas.DataFrame

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