Skip to content

Commit

Permalink
FIX-#7375: Fix Series.duplicated dropping name (#7395)
Browse files Browse the repository at this point in the history
* FIX-#7375: Fix Series.duplicated dropping name

Signed-off-by: Jonathan Shi <[email protected]>

* Update modin/pandas/series.py

Co-authored-by: Anatoly Myachev <[email protected]>

---------

Signed-off-by: Jonathan Shi <[email protected]>
Co-authored-by: Anatoly Myachev <[email protected]>
  • Loading branch information
noloerino and anmyachev authored Sep 14, 2024
1 parent 3e951a6 commit 05f5e7d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modin/pandas/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,12 @@ 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
if name is not None:
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 05f5e7d

Please sign in to comment.