-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
ENH: Add 'records' outtype to to_dict method. #4936
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
Conversation
|
grt....can you add a release notes entry (improvements), and a mention in v0.13.0? (use this PR ref as there is not associated issue) |
|
Updated the commit - let me know of anything else. |
pandas/tests/test_frame.py
Outdated
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 test isn't correct. It's dict and list, right? If so, you need to just use assertEqual without the for loops.
This would fail to detect a failure if recons_data were shorter than expected_records, if expected_records was missing certain keys, etc.)
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.
Good point... it's a list of dicts.
How could I test if nan == nan? I wanted to use the test case used in the other to_dict outtypes, but ran into that issue when I tried assertEqual first.
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.
I think tm.assert_almost_equal?
|
@jtratner I updated the test to with your suggestion, seems to have done the trick. |
|
ok....once more rebase and i think good 2 go (prob just release notes conflict) |
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.
you don't need the backslash here
|
thanks! |
|
Thanks for the feature! The resulting list of dicts has NumPy data types in entries, which is unfortunate -- difficult to serialize to JSON with known packages such as json. Is there a chance to have an option to convert entry types to native Python for this? Thanks |
to_jsonhas a records type that turns a DataFrame into arecords json string. It'd be nice if you could do a similar thing but not have to go
json.loads.