swat.cas.table.CASTable.replace

CASTable.replace(to_replace=None, value=None, inplace=False, limit=None, regex=False, method='pad', **kwargs)

Replace values in the data set

Parameters:
to_replacestr or regex or list or dict or Series or Numeric or None, optional
  • str or regex
    • str : string matching this value will be replaced with value

    • regex : string matching this pattern will be replaced with value

  • list-of-strings or list-of-regexes or list-of-numerics
    • This list must be the same length as value.

    • If regex=True, both this list and value are regexes.

  • dict
    • Dictionaries are of the form {‘col’: {‘value’: rep-value}}. The top-level contains the column names to match, the inner dictionary specifies the values to match and the replacement values.

  • None
    • This means that the regex= parameter contains the patterns to match.

valuescalar or dict or list or string or regex or None

Values to use as replacements. If a dict is specified, it takes the same form as a dictionary in the to_replace= parameter.

inplaceboolean, optional

If True, the table is modified in-place. If False, a new table is created.

limitint, optional

Not supported

regexboolean or same types as to_replace, optional

If True, the to_replace= and/or value= values are interpreted as regular expressions.

methodstring, optional

Not supported

Returns:
CASTable object
Raises:
AssertionError

If regex is not a boolean and to_replace is not None.

TypeError

If to_replace is None and value is not a list, dict, or Series. If to_replace is None and regex is a list, dict, or Series.

ValueError

If to_replace and value are lists, but are not the same length.