clarite.modify.make_categorical¶
-
clarite.modify.
make_categorical
(data: pandas.core.frame.DataFrame, skip: Union[str, List[str], None] = None, only: Union[str, List[str], None] = None)¶ Set variable types as Categorical
Converts the type to pd.Categorical
Parameters: - data: pd.DataFrame or pd.Series
Data to be processed
- skip: str, list or None (default is None)
List of variables that should not be made categorical
- only: str, list or None (default is None)
List of variables that are the only ones to be made categorical
Returns: - data: pd.DataFrame
DataFrame with the same data but validated and converted to categorical types
Examples
>>> import clarite >>> df = clarite.modify.make_categorical(df) ================================================================================ Running make_categorical -------------------------------------------------------------------------------- Set 12 of 12 variable(s) as categorical, each with 4,321 observations