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-#3896: Change Series.values to default to to_numpy(). #3979

Merged
merged 3 commits into from
Jan 23, 2022
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
2 changes: 1 addition & 1 deletion modin/pandas/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def values(self): # noqa: RT01, D200
"""
Return Series as ndarray or ndarray-like depending on the dtype.
"""
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was considering putting a:

UserWarning: 'Series.values` defaulting to to_numpy().

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not done for DataFrame.values.

Having this message for both DataFrame.values and Series.values is probably not super useful, except in the case where we're operating on an empty DataFrame/Series and we're already surfacing a

UserWarning: 'DataFrame.to_numpy` for empty DataFrame defaulting to pandas implementation.

in which case it will be confusing why DataFrame/Series using to_numpy and defaulting to pandas when the user is calling .values? (and the "values defaulting to to_numpy()" message would clarify).

return super(Series, self).to_numpy().flatten()
return self.to_numpy()

def add(self, other, level=None, fill_value=None, axis=0): # noqa: PR01, RT01, D200
"""
Expand Down
15 changes: 15 additions & 0 deletions modin/pandas/test/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3204,6 +3204,21 @@ def test_to_period():
)
def test_to_numpy(data):
modin_series, pandas_series = create_test_series(data)
assert_array_equal(modin_series.to_numpy(), pandas_series.to_numpy())


@pytest.mark.parametrize(
"data",
test_data_values + test_data_large_categorical_series_values,
ids=test_data_keys + test_data_large_categorical_series_keys,
)
def test_series_values(data):
modin_series, pandas_series = create_test_series(data)
assert_array_equal(modin_series.values, pandas_series.values)


def test_series_empty_values():
modin_series, pandas_series = pd.Series(), pandas.Series()
assert_array_equal(modin_series.values, pandas_series.values)


Expand Down