From f309f9ff4e525c8ec632f42e81b1f8abe566bc1f Mon Sep 17 00:00:00 2001 From: "Richard (Rick) Zamora" Date: Wed, 30 Nov 2022 18:26:47 -0600 Subject: [PATCH] Fix flaky `test_dataframe_aggregations_multilevel` (#9701) --- dask/dataframe/groupby.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dask/dataframe/groupby.py b/dask/dataframe/groupby.py index 1ba694bc0a3..5eeaab5a18c 100644 --- a/dask/dataframe/groupby.py +++ b/dask/dataframe/groupby.py @@ -532,7 +532,9 @@ def _mul_cols(df, cols): # Fix index in a groupby().apply() context # https://github.com/dask/dask/issues/8137 # https://github.com/pandas-dev/pandas/issues/43568 - _df.index = [0] * len(_df) + # Make sure index dtype is int (even if _df is empty) + # https://github.com/dask/dask/pull/9701 + _df.index = np.zeros(len(_df), dtype=int) return _df @@ -641,8 +643,10 @@ def _drop_duplicates_reindex(df): # Fix index in a groupby().apply() context # https://github.com/dask/dask/issues/8137 # https://github.com/pandas-dev/pandas/issues/43568 + # Make sure index dtype is int (even if result is empty) + # https://github.com/dask/dask/pull/9701 result = df.drop_duplicates() - result.index = [0] * len(result) + result.index = np.zeros(len(result), dtype=int) return result