DataFrame to dict with index orientation. #10844

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
2 participants
Contributor

gabrielaraujof commented Aug 18, 2015

The method DataFrame.to_dict didn't have an option for index orientation unlike its cousin to_json, which does have.

Contributor

jreback commented Aug 18, 2015

hmm, seems resonable. can you add a note in whatsnew / enhancements. (also add a versionadded tag in the doc-string).

jreback added this to the 0.17.0 milestone Aug 18, 2015

Contributor

gabrielaraujof commented Aug 20, 2015

Just added the note and the versionadded tag you asked. Should I've opened an issue before submit the pull request?
I was using pandas in a project and noticed the enhancement that method could have. Then I just thought in contribute, but I was unaware of the conventions.

@jreback jreback commented on an outdated diff Aug 20, 2015

doc/source/whatsnew/v0.17.0.txt
@@ -174,6 +174,8 @@ Other enhancements
- ``msgpack`` submodule has been updated to 0.4.6 with backward compatibility (:issue:`10581`)
+- ``DataFrame.to_dict`` now accepts the *index* option in ``orient`` keyword argument.
@jreback

jreback Aug 20, 2015

Contributor

use this PR number as the issue number

@jreback jreback commented on an outdated diff Aug 20, 2015

pandas/tests/test_frame.py
@@ -4473,9 +4473,15 @@ def test_to_dict(self):
tm.assert_almost_equal(recons_data, expected_records)
+ recons_data = DataFrame(test_data).to_dict("i")
@jreback

jreback Aug 20, 2015

Contributor

add the issue number as a comment here

Contributor

jreback commented Aug 20, 2015

minor corrections. pls squash. ping when green.

@jreback jreback added a commit that referenced this pull request Aug 21, 2015

@gabrielaraujof @jreback gabrielaraujof + jreback ENH: Index orientation option when converting a DataFrame into a dict,
…#10844

Added an index orient option for DataFrame.to_dict method.

Updated tests with index option.
73dcb95
Contributor

jreback commented Aug 21, 2015

merged via 73dcb95

thanks!

jreback closed this Aug 21, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment