Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX-#7375: Fix Series.duplicated dropping name #7395

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading