-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Maintain Dict Ordering with Concat #21512
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 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
87bb1ac
Fixes #21510 Remove sort if its already an ordered dict
SaturninoMateus f9d105e
Adding a space and new line to match PEP8. #21510
SaturninoMateus b044e04
Adding test case for concat OrderedDict and updating . #21510
SaturninoMateus eaa7cc0
Fixing v0.23.2.txt syntax . #21510
SaturninoMateus 6869e2c
Improving test case for orderedDict and whatsnew info. #21510
SaturninoMateus e9561fe
Refactoring test case code for orderedDict and improving whatsnew inf…
SaturninoMateus 53aca81
Fixing spaces to match with PEP8. #21510
SaturninoMateus 726755f
Merging upstream/master into my dev branch
SaturninoMateus a7aa052
Adding info about pd.concat method into whatsnew 0.24.0 #21510
SaturninoMateus 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
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.
Normal dicts are ordered too in python3.6+, that must be checked too. There is a
PY36
constant somewhere, that you can use for this check.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.
Not sure if we already took a stance on this as a project, but the orderedness of dicts in 3.6 is considered an implementation detail of cpython, while it will be a language feature starting from 3.7 . So in principle in 3.6 users should not rely on it, and we should not assume they do.
@topper-123 's comment still holds I think, but for 3.7
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.
Well we've already relied on that implementation detail in other changes (see #19830, #19859, #19884) so I'd be +1 on relying on that here as well
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.
Yeah, given that Python 3.6 is at 3.6.5 now, and its's being formalised in 3.7, I think this is quite safe. They're not going to change implementation now...
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.
This is very simliar to in structure to
pandas.core.common._dict_keys_to_ordered_list
. structure like this. see if we can consolidate all of these try/sorting routings.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.
@jreback you mean use:
keys = com._dict_keys_to_ordered_list(objs)
? If so, I'm afraid we'll need to refactor_dict_keys_to_ordered_list
because it assumes that PY36 has sorted dict which I think its not always true, and will breaktest_concat_dict
test case.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 that's the point i am raising, I want a refactor here.
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.
So, from
_dict_keys_to_ordered_list
method, i suggest change the conditionif PY36 or isinstance(mapping, OrderedDict):
toif PY37 or isinstance(mapping, OrderedDict):
then, removetest_constructor_dict_order_insertion
andtest_constructor_dict_order
. What do you think about it?