Repository: pandas-dev/pandas
File: pandas/core/arrays/arrow/array.py (Python)

Code before:

        Returns
        -------
        codes : ndarray
            An integer NumPy array that's an indexer into the original
            ArrowArray.
        uniques : ArrowArray
            An ArrowArray containing the unique values of `self`.

            .. note::

               uniques will *not* contain an entry for the NA value of
               the ArrowArray if there are any missing values present
               in `self`.

        See Also
        --------
        factorize : Top-level factorize method that dispatches here.

        Notes
        -----
        :meth:`pandas.factorize` offers a `sort` keyword as well.

        Examples
        --------
        >>> idx1 = pd.PeriodIndex(
        ...     ["2014-01", "2014-01", "2014-02", "2014-02", "2014-03", "2014-03"],
        ...     freq="M",
        ... )
        >>> arr, idx = idx1.factorize()
        >>> arr
        array([0, 0, 1, 1, 2, 2])
        >>> idx
        PeriodIndex(['2014-01', '2014-02', '2014-03'], dtype='period[M]')
        """
        null_encoding = "mask" if use_na_sentinel else "encode"

        data = self._pa_array

        if pa.types.is_dictionary(data.type):
            if null_encoding == "encode":
                # dictionary encode does nothing if an already encoded array is given
                data = data.cast(data.type.value_type)
                encoded = data.dictionary_encode(null_encoding=null_encoding)
            else:
                encoded = data
        else:
            encoded = data.dictionary_encode(null_encoding=null_encoding)
        if encoded.length() == 0:
            indices = np.array([], dtype=np.intp)
            uniques = self._from_pyarrow_array(

Review comment (suggestion):
A reminder to update all examples changed here to use `ArrowExtentionArray`

Code after:
        Returns
        -------
        codes : ndarray
            An integer NumPy array that's an indexer into the original
            ArrowArray.
        uniques : ArrowArray
            An ArrowArray containing the unique values of `self`.

            .. note::

               uniques will *not* contain an entry for the NA value of
               the ArrowArray if there are any missing values present
               in `self`.

        See Also
        --------
        factorize : Top-level factorize method that dispatches here.

        Notes
        -----
        :meth:`pandas.factorize` offers a `sort` keyword as well.

        Examples
        --------
        >>> arr = pd.array(
        ...     ["Ant", "Badger", "Cobra", "Cobra", "Deer", "Ant"], dtype=str
        ... )
        >>> arr_codes, arr_uniques = arr.factorize()
        >>> arr_codes
        array([0, 1, 2, 2, 3, 0])
        >>> arr_uniques
        <ArrowStringArray>
        ['Ant', 'Badger', 'Cobra', 'Deer']
        Length: 4, dtype: str
        """
        null_encoding = "mask" if use_na_sentinel else "encode"

        data = self._pa_array

        if pa.types.is_dictionary(data.type):
            if null_encoding == "encode":
                # dictionary encode does nothing if an already encoded array is given
                data = data.cast(data.type.value_type)
                encoded = data.dictionary_encode(null_encoding=null_encoding)
            else:
                encoded = data
        else:
            encoded = data.dictionary_encode(null_encoding=null_encoding)
        if encoded.length() == 0:
            indices = np.array([], dtype=np.intp)
            uniques = self._from_pyarrow_array(