-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Respect Key Ordering for OrderedDict List in DataFrame Init #13309
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
ENH: Respect Key Ordering for OrderedDict List in DataFrame Init #13309
Conversation
Current coverage is 84.22%@@ master #13309 diff @@
==========================================
Files 138 138
Lines 50681 50666 -15
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 42682 42672 -10
+ Misses 7999 7994 -5
Partials 0 0
|
@@ -5537,7 +5537,8 @@ def _list_of_series_to_arrays(data, columns, coerce_float=False, dtype=None): | |||
def _list_of_dict_to_arrays(data, columns, coerce_float=False, dtype=None): | |||
if columns is None: | |||
gen = (list(x.keys()) for x in data) | |||
columns = lib.fast_unique_multiple_list_gen(gen) | |||
columns = lib.fast_unique_multiple_list_gen( | |||
gen, sort=(not isinstance(data[0], OrderedDict))) |
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.
should be not any(isinstance(d, OrderedDict) for d in data)
I think. (a bit odd if that actually happens, though)
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.
Indeed, but done.
54b4f9a
to
448eee8
Compare
|
||
row_three = {'b': 2, 'a': 1} | ||
|
||
expected = DataFrame([[2, 1], [2, 1]], columns=['b', 'a']) |
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.
does this hit your code path? e.g. columns
is not None 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.
That statement does not because no dict objects are being passed in.
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.
still need a test for a mix of dict/OrderedDIct being passed.
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, that's my last test (see below)
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.
ahh ok
27b7a69
to
2a600fc
Compare
2a600fc
to
4f311cc
Compare
@jreback : Travis is giving the green light. Ready to merge if there are no other concerns. |
data['b'] = 2 | ||
data['a'] = 1 | ||
|
||
result = DataFrame([data]) |
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.
like this, but for example have a dict and OrderedDict in a list
ty sir! |
Title is self-explanatory. Closes #13304.