-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Added Index param to to_dict like in to_json #46398 #46784
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
Hello, it's my first time contributing! I'm not sure why pre-commit.ci is timing out. I ran pre-commit locally and all the checks seemed to pass fine. Any suggestions on what might be going wrong? |
@@ -1909,43 +1914,77 @@ def to_dict(self, orient: str = "dict", into=dict): | |||
elif orient.startswith("i"): | |||
orient = "index" | |||
|
|||
if not index and orient not in ["split", "tight"]: |
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 am not sure this is desireable. The default config of index should not lead to a ValueError
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.
Hey phofl! Thanks for the feedback! I assume you mean the default value for the index parameter - the default value for the index parameter is True, so it wouldn't lead to a ValueError. This check was directly taken from the implementation of the index parameter in 'to_json'. It checks that index is only True if orient is 'split' or 'tight'. A value error would be raised only when index is set to False AND orient is not 'split' or 'tight'.
@@ -344,3 +344,19 @@ def test_to_dict_orient_tight(self, index, columns): | |||
roundtrip = DataFrame.from_dict(df.to_dict(orient="tight"), orient="tight") | |||
|
|||
tm.assert_frame_equal(df, roundtrip) | |||
|
|||
def test_to_dict_index_orient_split(self): |
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.
Could you add the gh reference?
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
Thanks for the pull request, but it appears to have gone stale. If interested in contributing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen. |
index
param toto_dict
like into_json
. #46398doc/source/whatsnew/v1.5.0.rst
file if fixing a bug or adding a new feature.