pandas.api.extensions.ExtensionArray.factorize#
- ExtensionArray.factorize(na_sentinel=_NoDefault.no_default, use_na_sentinel=_NoDefault.no_default)[source]#
Encode the extension array as an enumerated type.
- Parameters
- na_sentinelint, default -1
Value to use in the codes array to indicate missing values.
Deprecated since version 1.5.0: The na_sentinel argument is deprecated and will be removed in a future version of pandas. Specify use_na_sentinel as either True or False.
- use_na_sentinelbool, default True
If True, the sentinel -1 will be used for NaN values. If False, NaN values will be encoded as non-negative integers and will not drop the NaN from the uniques of the values.
New in version 1.5.0.
- Returns
- codesndarray
An integer NumPy array that’s an indexer into the original ExtensionArray.
- uniquesExtensionArray
An ExtensionArray containing the unique values of self.
Note
uniques will not contain an entry for the NA value of the ExtensionArray if there are any missing values present in self.
See also
factorize
Top-level factorize method that dispatches here.
Notes
pandas.factorize()
offers a sort keyword as well.