Skip to content

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

Closed
wants to merge 5 commits into from

Conversation

vruthik
Copy link

@vruthik vruthik commented Apr 15, 2022

@vruthik
Copy link
Author

vruthik commented Apr 20, 2022

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"]:
Copy link
Member

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

Copy link
Author

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):
Copy link
Member

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?

@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot added the Stale label May 27, 2022
@mroeschke
Copy link
Member

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.

@mroeschke mroeschke closed this Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add index param to to_dict like in to_json.
3 participants