Skip to content

Commit

Permalink
FIX-1708: Don't sort indexes in Series functions with level parameter (
Browse files Browse the repository at this point in the history
…#1830)

Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev authored Jul 28, 2020
1 parent a95ddf9 commit f43a70a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modin/pandas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,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

0 comments on commit f43a70a

Please sign in to comment.