Skip to content

Commit

Permalink
FIX-#7375: Fix Series.duplicated dropping name
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Shi <[email protected]>
  • Loading branch information
noloerino committed Sep 12, 2024
1 parent 3357709 commit 11e5883
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modin/pandas/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,11 @@ def duplicated(self, keep="first") -> Series: # noqa: PR01, RT01, D200
"""
Indicate duplicate Series values.
"""
return self.to_frame().duplicated(keep=keep)
name = self.name
result = self.to_frame().duplicated(keep=keep)
# DataFrame.duplicated drops the name, so we need to manually restore it
result.name = name
return result

def eq(
self, other, level=None, fill_value=None, axis=0
Expand Down
6 changes: 6 additions & 0 deletions modin/tests/pandas/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1942,6 +1942,12 @@ def test_duplicated(data, keep):
df_equals(modin_result, pandas_series.duplicated(keep=keep))


def test_duplicated_keeps_name_issue_7375():
# Ensure that the name property of a series is preserved across duplicated
modin_series, pandas_series = create_test_series([1, 2, 3, 1], name="a")
df_equals(modin_series.duplicated(), pandas_series.duplicated())


@pytest.mark.parametrize("data", test_data_values, ids=test_data_keys)
def test_empty(data):
modin_series, pandas_series = create_test_series(data)
Expand Down

0 comments on commit 11e5883

Please sign in to comment.