Skip to content

Commit a7eb2aa

Browse files
further simplification
1 parent 2ab9c0c commit a7eb2aa

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
@@ -1963,16 +1963,19 @@ def items_overlap_with_suffix(left, lsuffix, right, rsuffix):
19631963
raise ValueError('columns overlap but no suffix specified: '
19641964
'{rename}'.format(rename=to_rename))
19651965

1966-
def lrenamer(x):
1967-
if x in to_rename and lsuffix is not None:
1968-
return '{x}{lsuffix}'.format(x=x, lsuffix=lsuffix)
1969-
return x
1966+
def renamer(x, suffix):
1967+
"""Rename the left and right indices.
19701968
1971-
def rrenamer(x):
1972-
if x in to_rename and rsuffix is not None:
1973-
return '{x}{rsuffix}'.format(x=x, rsuffix=rsuffix)
1969+
If there is overlap, and suffix is not None, add
1970+
suffix, otherwise, leave it as-is.
1971+
"""
1972+
if x in to_rename and suffix is not None:
1973+
return '{x}{suffix}'.format(x=x, suffix=suffix)
19741974
return x
19751975

1976+
lrenamer = partial(renamer, suffix=lsuffix)
1977+
rrenamer = partial(renamer, suffix=rsuffix)
1978+
19761979
return (_transform_index(left, lrenamer),
19771980
_transform_index(right, rrenamer))
19781981

0 commit comments

Comments
 (0)