Skip to content

Commit 74eedbc

Browse files
authored
CLN/TYP: remove unused arguments in merge (#40513)
1 parent 7d43b2d commit 74eedbc

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

pandas/core/reshape/merge.py

+21-25
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import string
1111
from typing import (
1212
TYPE_CHECKING,
13+
Hashable,
14+
List,
1315
Optional,
1416
Tuple,
1517
cast,
@@ -124,14 +126,13 @@ def merge(
124126
merge.__doc__ = _merge_doc % "\nleft : DataFrame"
125127

126128

127-
def _groupby_and_merge(by, on, left: DataFrame, right: DataFrame, merge_pieces):
129+
def _groupby_and_merge(by, left: DataFrame, right: DataFrame, merge_pieces):
128130
"""
129131
groupby & merge; we are always performing a left-by type operation
130132
131133
Parameters
132134
----------
133135
by: field to group
134-
on: duplicates field
135136
left: DataFrame
136137
right: DataFrame
137138
merge_pieces: function for merging
@@ -307,17 +308,15 @@ def _merger(x, y):
307308
check = set(left_by).difference(left.columns)
308309
if len(check) != 0:
309310
raise KeyError(f"{check} not found in left columns")
310-
result, _ = _groupby_and_merge(
311-
left_by, on, left, right, lambda x, y: _merger(x, y)
312-
)
311+
result, _ = _groupby_and_merge(left_by, left, right, lambda x, y: _merger(x, y))
313312
elif right_by is not None:
314313
if isinstance(right_by, str):
315314
right_by = [right_by]
316315
check = set(right_by).difference(right.columns)
317316
if len(check) != 0:
318317
raise KeyError(f"{check} not found in right columns")
319318
result, _ = _groupby_and_merge(
320-
right_by, on, right, left, lambda x, y: _merger(y, x)
319+
right_by, right, left, lambda x, y: _merger(y, x)
321320
)
322321
else:
323322
result = _merger(left, right)
@@ -708,7 +707,7 @@ def __init__(
708707
if validate is not None:
709708
self._validate(validate)
710709

711-
def get_result(self):
710+
def get_result(self) -> DataFrame:
712711
if self.indicator:
713712
self.left, self.right = self._indicator_pre_merge(self.left, self.right)
714713

@@ -774,7 +773,7 @@ def _indicator_pre_merge(
774773

775774
return left, right
776775

777-
def _indicator_post_merge(self, result):
776+
def _indicator_post_merge(self, result: DataFrame) -> DataFrame:
778777

779778
result["_left_indicator"] = result["_left_indicator"].fillna(0)
780779
result["_right_indicator"] = result["_right_indicator"].fillna(0)
@@ -790,7 +789,7 @@ def _indicator_post_merge(self, result):
790789
result = result.drop(labels=["_left_indicator", "_right_indicator"], axis=1)
791790
return result
792791

793-
def _maybe_restore_index_levels(self, result):
792+
def _maybe_restore_index_levels(self, result: DataFrame) -> None:
794793
"""
795794
Restore index levels specified as `on` parameters
796795
@@ -949,7 +948,6 @@ def _get_join_info(self):
949948
self.left.index,
950949
self.right.index,
951950
left_indexer,
952-
right_indexer,
953951
how="right",
954952
)
955953
else:
@@ -961,7 +959,6 @@ def _get_join_info(self):
961959
self.right.index,
962960
self.left.index,
963961
right_indexer,
964-
left_indexer,
965962
how="left",
966963
)
967964
else:
@@ -979,9 +976,8 @@ def _create_join_index(
979976
index: Index,
980977
other_index: Index,
981978
indexer,
982-
other_indexer,
983979
how: str = "left",
984-
):
980+
) -> Index:
985981
"""
986982
Create a join index by rearranging one index to match another
987983
@@ -1126,7 +1122,7 @@ def _get_merge_keys(self):
11261122

11271123
return left_keys, right_keys, join_names
11281124

1129-
def _maybe_coerce_merge_keys(self):
1125+
def _maybe_coerce_merge_keys(self) -> None:
11301126
# we have valid merges but we may have to further
11311127
# coerce these if they are originally incompatible types
11321128
#
@@ -1285,7 +1281,7 @@ def _create_cross_configuration(
12851281
cross_col,
12861282
)
12871283

1288-
def _validate_specification(self):
1284+
def _validate_specification(self) -> None:
12891285
if self.how == "cross":
12901286
if (
12911287
self.left_index
@@ -1372,7 +1368,7 @@ def _validate_specification(self):
13721368
if self.how != "cross" and len(self.right_on) != len(self.left_on):
13731369
raise ValueError("len(right_on) must equal len(left_on)")
13741370

1375-
def _validate(self, validate: str):
1371+
def _validate(self, validate: str) -> None:
13761372

13771373
# Check uniqueness of each
13781374
if self.left_index:
@@ -1479,10 +1475,10 @@ def restore_dropped_levels_multijoin(
14791475
left: MultiIndex,
14801476
right: MultiIndex,
14811477
dropped_level_names,
1482-
join_index,
1483-
lindexer,
1484-
rindexer,
1485-
):
1478+
join_index: Index,
1479+
lindexer: np.ndarray,
1480+
rindexer: np.ndarray,
1481+
) -> Tuple[List[Index], np.ndarray, List[Hashable]]:
14861482
"""
14871483
*this is an internal non-public method*
14881484
@@ -1500,7 +1496,7 @@ def restore_dropped_levels_multijoin(
15001496
right index
15011497
dropped_level_names : str array
15021498
list of non-common level names
1503-
join_index : MultiIndex
1499+
join_index : Index
15041500
the index of the join between the
15051501
common levels of left and right
15061502
lindexer : intp array
@@ -1514,8 +1510,8 @@ def restore_dropped_levels_multijoin(
15141510
levels of combined multiindexes
15151511
labels : intp array
15161512
labels of combined multiindexes
1517-
names : str array
1518-
names of combined multiindexes
1513+
names : List[Hashable]
1514+
names of combined multiindex levels
15191515
15201516
"""
15211517

@@ -1604,7 +1600,7 @@ def __init__(
16041600
sort=True, # factorize sorts
16051601
)
16061602

1607-
def get_result(self):
1603+
def get_result(self) -> DataFrame:
16081604
join_index, left_indexer, right_indexer = self._get_join_info()
16091605

16101606
llabels, rlabels = _items_overlap_with_suffix(
@@ -1653,7 +1649,7 @@ def _asof_by_function(direction: str):
16531649
}
16541650

16551651

1656-
def _get_cython_type_upcast(dtype):
1652+
def _get_cython_type_upcast(dtype) -> str:
16571653
""" Upcast a dtype to 'int64_t', 'double', or 'object' """
16581654
if is_integer_dtype(dtype):
16591655
return "int64_t"

0 commit comments

Comments
 (0)