Skip to content

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

Closed

Conversation

gfyoung
Copy link
Member

@gfyoung gfyoung commented May 28, 2016

Title is self-explanatory. Closes #13304.

@codecov-io
Copy link

codecov-io commented May 28, 2016

Current coverage is 84.22%

Merging #13309 into master will increase coverage by <.01%

@@             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          

Powered by Codecov. Last updated by 9e7bfdd...87eba3d

@@ -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)))
Copy link
Contributor

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)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, but done.

@gfyoung gfyoung force-pushed the ordereddict-key-ordering-init branch 4 times, most recently from 54b4f9a to 448eee8 Compare May 28, 2016 22:32

row_three = {'b': 2, 'a': 1}

expected = DataFrame([[2, 1], [2, 1]], columns=['b', 'a'])
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh ok

@jreback jreback added Enhancement Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels May 29, 2016
@gfyoung gfyoung force-pushed the ordereddict-key-ordering-init branch 2 times, most recently from 27b7a69 to 2a600fc Compare May 30, 2016 21:30
@gfyoung gfyoung force-pushed the ordereddict-key-ordering-init branch from 2a600fc to 4f311cc Compare May 30, 2016 21:31
@gfyoung
Copy link
Member Author

gfyoung commented May 31, 2016

@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])
Copy link
Contributor

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

@jreback jreback added this to the 0.18.2 milestone May 31, 2016
@jreback jreback closed this in d191640 May 31, 2016
@jreback
Copy link
Contributor

jreback commented May 31, 2016

ty sir!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants