def add_keys(self, keys, nulls=None): """ Create new category adding the specified keys and remapping values to the new key indexes. Parameters ---------- keys : nvstrings or ndarray keys to be added to existing keys nulls: bitmask ndarray of type uint8 Examples -------- >>> import nvcategory >>> import numpy as np >>> c = nvcategory.from_numbers(np.array([4, 1, 2, 3, 2, 1, 4])) >>> print(c.keys(),c.values()) [1, 2, 3, 4] [3, 0, 1, 2, 1, 0, 3] >>> nc = c.add_keys(np.array([2,1,0,3])) >>> print(nc.keys(),nc.values()) [0, 1, 2, 3, 4] [4, 1, 2, 3, 2, 1, 4] """ rtn = pyniNVCategory.n_add_keys(self.m_cptr, keys, nulls) if rtn is not None: rtn = nvcategory(rtn) return rtn
def add_keys(self, strs): """ Create new category adding the specified keys and remapping values to the new key indexes. Parameters ---------- strs : nvstrings keys to be added to existing keys """ rtn = pyniNVCategory.n_add_keys(self.m_cptr, strs) if rtn is not None: rtn = nvcategory(rtn) return rtn