DataFrame.categorize(columns=None, index=None, split_every=None, **kwargs)[source]

Convert columns of the DataFrame to category dtype.


This method eagerly computes the categories of the chosen columns.

columnslist, optional

A list of column names to convert to categoricals. By default any column with an object dtype is converted to a categorical, and any unknown categoricals are made known.

indexbool, optional

Whether to categorize the index. By default, object indices are converted to categorical, and unknown categorical indices are made known. Set True to always categorize the index, False to never.

split_everyint, optional

Group partitions into groups of this size while performing a tree-reduction. If set to False, no tree-reduction will be used.


Keyword arguments are passed on to compute.