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-1708: Don't sort indexes in Series functions with level parameter #1830

Merged
merged 1 commit into from
Jul 28, 2020
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/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def _handle_level_agg(self, axis, level, op, **kwargs):
level: The level of the axis to apply the operation on
op: String representation of the operation to be performed on the level
"""
return getattr(self.groupby(level=level, axis=axis), op)(**kwargs)
return getattr(self.groupby(level=level, axis=axis, sort=False), op)(**kwargs)

def _validate_other(
self,
Expand Down
19 changes: 19 additions & 0 deletions modin/pandas/test/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
df_equals,
arg_keys,
name_contains,
test_data,
test_data_values,
test_data_keys,
test_string_data_values,
Expand Down Expand Up @@ -1802,6 +1803,24 @@ def test_last():
df_equals(modin_series.last("20D"), pandas_series.last("20D"))


def test_index_order():
# see #1708 for details
s_modin, s_pandas = create_test_series(test_data["dense_nan_data"])
rows_number = len(s_modin.index)
level_0 = np.random.choice([x for x in range(10)], rows_number)
level_1 = np.random.choice([x for x in range(10)], rows_number)
index = pandas.MultiIndex.from_arrays([level_0, level_1])

s_modin.index = index
s_pandas.index = index

for func in ["all", "any", "mad"]:
df_equals(
getattr(s_modin, func)(level=0).index,
getattr(s_pandas, func)(level=0).index,
)


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