Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Performance improvements
- Performance improvement in :func:`merge` for many-to-one joins with unique right keys (:issue:`38418`)
- Performance improvement in :func:`merge` with ``how="cross"`` (:issue:`38082`)
- Performance improvement in :func:`merge` with ``how="left"`` (:issue:`64370`)
- Performance improvement in :func:`merge` with ``how="left"`` and ``sort=False`` when joining on a right index with unique keys (:issue:`65160`)
- Performance improvement in :func:`merge` with ``sort=False`` for single-key ``how="left"``/``how="right"`` joins when the opposite join key is sorted, unique, and range-like (:issue:`64146`)
- Performance improvement in :func:`read_csv` with ``engine="c"`` when reading from binary file-like objects (e.g. PyArrow S3 file handles) by avoiding unnecessary ``TextIOWrapper`` wrapping (:issue:`46823`)
- Performance improvement in :func:`read_html` and the Python CSV parser when ``thousands`` is set, fixing catastrophic regex backtracking on cells with many comma-separated digit groups followed by non-numeric text (:issue:`52619`)
Expand Down
11 changes: 7 additions & 4 deletions pandas/core/reshape/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2816,10 +2816,13 @@ def _left_join_on_index(
# variable has type "ndarray[Any, dtype[signedinteger[Any]]]")
rkey = right_ax._values # type: ignore[assignment]

left_key, right_key, count = _factorize_keys(lkey, rkey, sort=sort)
left_indexer, right_indexer = libjoin.left_outer_join(
left_key, right_key, count, sort=sort
)
left_key, right_key, count = _factorize_keys(lkey, rkey, sort=sort, how="left")
if count == -1:
left_indexer, right_indexer = left_key, right_key
else:
left_indexer, right_indexer = libjoin.left_outer_join(
left_key, right_key, count, sort=sort
)

if sort or len(left_ax) != len(left_indexer):
# if asked to sort or there are 1-to-many matches
Expand Down
Loading