-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: DataFrame.sort_index broken if not both lexsorted and monotonic in levels #15694
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
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
47c67d6
BUG: construct MultiIndex identically from levels/labels when concatting
jreback 7be8941
incorrectly raising KeyError rather than UnsortedIndexError, caught b…
jreback b234bdb
support for removing unused levels (internally)
jreback 269cb3b
small doc updates
jreback 3c4ca22
add degenerate test case
jreback f2ddc9c
replace _reconstruct with: sort_monotonic, and remove_unused_levels (…
jreback 520c9c1
versionadded tags
jreback 527c3a6
simpler algo for remove_used_levels
jreback 48249ab
add doc example
jreback 31097fc
add doc-strings, rename sort_monotonic -> sort_levels_monotonic
jreback bd17d2b
rename sort_index_montonic -> _sort_index_monotonic
jreback File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1882,6 +1882,13 @@ def get_group_levels(self): | |
'ohlc': lambda *args: ['open', 'high', 'low', 'close'] | ||
} | ||
|
||
def _is_builtin_func(self, arg): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ignore this, was actually an unrelated bug as this wasn't defined on BaseGrouper |
||
""" | ||
if we define an builtin function for this argument, return it, | ||
otherwise return the arg | ||
""" | ||
return SelectionMixin._builtin_table.get(arg, arg) | ||
|
||
def _get_cython_function(self, kind, how, values, is_numeric): | ||
|
||
dtype_str = values.dtype.name | ||
|
@@ -2107,7 +2114,7 @@ def _aggregate_series_fast(self, obj, func): | |
# avoids object / Series creation overhead | ||
dummy = obj._get_values(slice(None, 0)).to_dense() | ||
indexer = get_group_index_sorter(group_index, ngroups) | ||
obj = obj.take(indexer, convert=False) | ||
obj = obj.take(indexer, convert=False).to_dense() | ||
group_index = algorithms.take_nd( | ||
group_index, indexer, allow_fill=False) | ||
grouper = lib.SeriesGrouper(obj, func, group_index, ngroups, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
level can be 0 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes in fact this was what prevented
.sort_index()
and.sort_index(level=0)
from being the same.