Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
phofl committed Sep 7, 2023
1 parent 5d7151d commit de02cb0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/reference/extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ objects.
api.extensions.ExtensionArray._accumulate
api.extensions.ExtensionArray._concat_same_type
api.extensions.ExtensionArray._factorize_with_other_for_merge
api.extensions.ExtensionArray._formatter
api.extensions.ExtensionArray._from_factorized
api.extensions.ExtensionArray._from_sequence
Expand Down
14 changes: 14 additions & 0 deletions pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2270,6 +2270,20 @@ def _groupby_op(
def _factorize_with_other_for_merge(
self, other: Self, sort: bool = False
) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp], int]:
"""Factorizes two arrays to get codes for merge operations.
This allows extension array authors to implement efficient factorizations
for merge operations.
Parameters
----------
other : ExtensionArray with the same dtype as self.
sort : Whether to sort the result.
Returns
-------
tuple of codes for left and right and the number of unique elements.
"""
lk, _ = self._values_for_factorize()
rk, _ = other._values_for_factorize()
return factorize_arrays(lk, rk, sort)
Expand Down

0 comments on commit de02cb0

Please sign in to comment.