def find_and_replace(self, to_replace, value): """ Return col with *to_replace* replaced with *value*. """ to_replace_col = columnops.as_column(to_replace) value_col = columnops.as_column(value) replaced = self.copy() to_replace_col, value_col, replaced = numeric_normalize_types( to_replace_col, value_col, replaced) cpp_replace.replace(replaced, to_replace_col, value_col) return replaced
def find_and_replace(self, to_replace, value): """ Return col with *to_replace* replaced with *value*. """ replaced = columnops.as_column(self.cat().codes) to_replace_col = columnops.as_column( np.asarray([self._encode(val) for val in to_replace], dtype=replaced.dtype)) value_col = columnops.as_column( np.asarray([self._encode(val) for val in value], dtype=replaced.dtype)) cpp_replace.replace(replaced, to_replace_col, value_col) return self.replace(data=replaced.data)
def find_and_replace(self, to_replace, replacement, all_nan): """ Return col with *to_replace* replaced with *value*. """ to_replace_col = columnops.as_column(to_replace) replacement_dtype = self.dtype if all_nan else None replacement_col = columnops.as_column(replacement, dtype=replacement_dtype) replaced = self.copy() to_replace_col, replacement_col, replaced = numeric_normalize_types( to_replace_col, replacement_col, replaced) output = cpp_replace.replace(replaced, to_replace_col, replacement_col) return output
def find_and_replace(self, to_replace, replacement, all_nan): """ Return col with *to_replace* replaced with *replacement*. """ replaced = columnops.as_column(self.cat().codes) to_replace_col = columnops.as_column( np.asarray([self._encode(val) for val in to_replace], dtype=replaced.dtype)) replacement_col = columnops.as_column( np.asarray([self._encode(val) for val in replacement], dtype=replaced.dtype)) output = cpp_replace.replace(replaced, to_replace_col, replacement_col) return self.replace(data=output.data)