Skip to content

Commit e754fae

Browse files
authored
REF: make copy keyword non-stateful (#48062)
1 parent d5b4b33 commit e754fae

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

pandas/core/reshape/merge.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,10 @@ def merge(
118118
right_index=right_index,
119119
sort=sort,
120120
suffixes=suffixes,
121-
copy=copy,
122121
indicator=indicator,
123122
validate=validate,
124123
)
125-
return op.get_result()
124+
return op.get_result(copy=copy)
126125

127126

128127
if __debug__:
@@ -624,7 +623,6 @@ def __init__(
624623
right_index: bool = False,
625624
sort: bool = True,
626625
suffixes: Suffixes = ("_x", "_y"),
627-
copy: bool = True,
628626
indicator: bool = False,
629627
validate: str | None = None,
630628
) -> None:
@@ -641,7 +639,6 @@ def __init__(
641639

642640
self.on = com.maybe_make_list(on)
643641

644-
self.copy = copy
645642
self.suffixes = suffixes
646643
self.sort = sort
647644

@@ -702,7 +699,7 @@ def __init__(
702699
if validate is not None:
703700
self._validate(validate)
704701

705-
def get_result(self) -> DataFrame:
702+
def get_result(self, copy: bool = True) -> DataFrame:
706703
if self.indicator:
707704
self.left, self.right = self._indicator_pre_merge(self.left, self.right)
708705

@@ -719,7 +716,7 @@ def get_result(self) -> DataFrame:
719716
[(self.left._mgr, lindexers), (self.right._mgr, rindexers)],
720717
axes=[llabels.append(rlabels), join_index],
721718
concat_axis=0,
722-
copy=self.copy,
719+
copy=copy,
723720
)
724721

725722
typ = self.left._constructor
@@ -1100,7 +1097,7 @@ def _get_merge_keys(self):
11001097
else:
11011098
# work-around for merge_asof(right_index=True)
11021099
right_keys.append(right.index)
1103-
if lk is not None and lk == rk:
1100+
if lk is not None and lk == rk: # FIXME: what about other NAs?
11041101
# avoid key upcast in corner case (length-0)
11051102
if len(left) > 0:
11061103
right_drop.append(rk)
@@ -1641,7 +1638,6 @@ def __init__(
16411638
right_index: bool = False,
16421639
axis: int = 1,
16431640
suffixes: Suffixes = ("_x", "_y"),
1644-
copy: bool = True,
16451641
fill_method: str | None = None,
16461642
how: str = "outer",
16471643
) -> None:
@@ -1662,7 +1658,7 @@ def __init__(
16621658
sort=True, # factorize sorts
16631659
)
16641660

1665-
def get_result(self) -> DataFrame:
1661+
def get_result(self, copy: bool = True) -> DataFrame:
16661662
join_index, left_indexer, right_indexer = self._get_join_info()
16671663

16681664
llabels, rlabels = _items_overlap_with_suffix(
@@ -1691,7 +1687,7 @@ def get_result(self) -> DataFrame:
16911687
[(self.left._mgr, lindexers), (self.right._mgr, rindexers)],
16921688
axes=[llabels.append(rlabels), join_index],
16931689
concat_axis=0,
1694-
copy=self.copy,
1690+
copy=copy,
16951691
)
16961692

16971693
typ = self.left._constructor

0 commit comments

Comments
 (0)