BUG: fix compatibility issue of df.sort_index() and df.groupby(sort=True) #776
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What do these changes do?
sort_index
Xorbits' DataFrame
sort_index
is inconsistent with pandas whenaxis=1
andignore_index=True
.pandas does it by sorting the index as usual and replacing index (when axis=0) or columns (when axis=1) with RangeIndex.
Here is the reference code.
So here we follow pandas and replace index or columns when
ignore_index=True
is passed.groupby(sort=True).agg()
python/xorbits/_mars/dataframe/groupby/sort.py
:In the latest version, during the map phase of DataFrameGroupbySortShuffle, if
in_df
does not contain the index from pivots, an emptyout_df
is returned.Related issue number
Check code requirements