Skip to content

Commit f086feb

Browse files
further simplification
1 parent 0da71fe commit f086feb

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

pandas/core/internals/managers.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -1971,16 +1971,19 @@ def items_overlap_with_suffix(left, lsuffix, right, rsuffix):
19711971
raise ValueError('columns overlap but no suffix specified: '
19721972
'{rename}'.format(rename=to_rename))
19731973

1974-
def lrenamer(x):
1975-
if x in to_rename and lsuffix is not None:
1976-
return '{x}{lsuffix}'.format(x=x, lsuffix=lsuffix)
1977-
return x
1974+
def renamer(x, suffix):
1975+
"""Rename the left and right indices.
19781976
1979-
def rrenamer(x):
1980-
if x in to_rename and rsuffix is not None:
1981-
return '{x}{rsuffix}'.format(x=x, rsuffix=rsuffix)
1977+
If there is overlap, and suffix is not None, add
1978+
suffix, otherwise, leave it as-is.
1979+
"""
1980+
if x in to_rename and suffix is not None:
1981+
return '{x}{suffix}'.format(x=x, suffix=suffix)
19821982
return x
19831983

1984+
lrenamer = partial(renamer, suffix=lsuffix)
1985+
rrenamer = partial(renamer, suffix=rsuffix)
1986+
19841987
return (_transform_index(left, lrenamer),
19851988
_transform_index(right, rrenamer))
19861989

0 commit comments

Comments
 (0)