pipette.categorize

pipette.categorize(x: DataFrame | Series, *, columns: list[str] | None = None) DataFrame | Series

Convert columns to Categorical.

Parameters:
  • x (pd.DataFrame or pd.Series) – Input data.

  • columns (list of str, optional) – Column names to convert. Only valid for a DataFrame. If None on a DataFrame, converts every string-like column that contains duplicate values. Required to be None for a Series.

Returns:

Same type as input, with the selected columns (or the Series itself) converted to Categorical.

Return type:

pd.DataFrame or pd.Series