示例#1
0
    def remove_keys(self, keys, nulls=None):
        """
        Create new category removing the specified keys and remapping
        values to the new key indexes. Values with removed keys are
        mapped to -1.

        Parameters
        ----------
        keys : nvstrings or ndarray
            keys to be removed from 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.remove_keys(np.array([4,0]))
        >>> print(nc.keys(),nc.values())
        [1, 2, 3] [-1, 0, 1, 2, 1, 0, -1]

        """
        rtn = pyniNVCategory.n_remove_keys(self.m_cptr, keys, nulls)
        if rtn is not None:
            rtn = nvcategory(rtn)
        return rtn
示例#2
0
    def remove_keys(self, strs):
        """
        Create new category removing the specified keys and remapping
        values to the new key indexes. Values with removed keys are
        mapped to -1.

        Parameters
        ----------
        strs : nvstrings
            keys to be removed from existing keys
        """
        rtn = pyniNVCategory.n_remove_keys(self.m_cptr, strs)
        if rtn is not None:
            rtn = nvcategory(rtn)
        return rtn