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-#6227: Make sure Series.unique() with pyarrow dtype returns ArrowExtensionArray #35

Closed
Closed
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
4 changes: 1 addition & 3 deletions modin/pandas/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2048,9 +2048,7 @@ def unique(self): # noqa: RT01, D200
"""
Return unique values of Series object.
"""
return self.__constructor__(
query_compiler=self._query_compiler.unique()
).to_numpy()
return self._query_compiler.unique().to_pandas().squeeze(axis=1).values

def update(self, other): # noqa: PR01, D200
"""
Expand Down
13 changes: 13 additions & 0 deletions modin/pandas/test/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3575,6 +3575,19 @@ def test_unique(data):
assert modin_result.shape == pandas_result.shape


def test_unique_pyarrow_dtype():
# See #6227 for details
modin_series, pandas_series = create_test_series(
[1, 0, pd.NA], dtype="uint8[pyarrow]"
)
modin_result = modin_series.unique()
pandas_result = pandas_series.unique()

df_equals(modin_result, pandas_result)
# to be sure `unique` return `ArrowExtensionArray`
assert type(pandas_result) is type(modin_result)


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