Skip to content

Improve error message for DataFrame.from_dict when wrong orient is provided #47451

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

Merged
merged 17 commits into from
Jun 24, 2022

Conversation

KianShah
Copy link
Contributor

@KianShah KianShah commented Jun 21, 2022

@KianShah
Copy link
Contributor Author

I don't think any tests are needed for this, since it really is such a small fix. Could be wrong though :/

Copy link
Member

@phofl phofl left a comment

Choose a reason for hiding this comment

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

small comments, might also break tests if error message was checked

@KianShah
Copy link
Contributor Author

Damn yall really test everything lol. Ok I will fix the failing test, at least now I have a good idea of which test to fix.

@phofl
Copy link
Member

phofl commented Jun 21, 2022

I think these failures are unrelated

@KianShah
Copy link
Contributor Author

Ah. Ok I will write new tests then

Copy link
Contributor Author

@KianShah KianShah left a comment

Choose a reason for hiding this comment

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

Made requested changes.

Was unable to test locally, due to failing test elsewhere, so I will leave it to CI to run this test

@KianShah KianShah requested a review from phofl June 22, 2022 00:02
Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

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

Nice fix, thanks for working on this. lgtm, just added couple of suggestions.

@datapythonista datapythonista changed the title Fix error msg Improve error message for DataFrame.from_dict when wrong orient is provided Jun 22, 2022
@datapythonista datapythonista added Error Reporting Incorrect or improved errors from pandas Constructors Series/DataFrame/Index/pd.array Constructors labels Jun 22, 2022
@@ -189,3 +184,16 @@ def test_frame_dict_constructor_empty_series(self):
# it works!
DataFrame({"foo": s1, "bar": s2, "baz": s3})
DataFrame.from_dict({"foo": s1, "baz": s3, "bar": s2})

def test_from_dict_scalars_requires_index(self):
Copy link
Contributor Author

@KianShah KianShah Jun 23, 2022

Choose a reason for hiding this comment

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

Note: I moved this function down here, so that all functions that test exception behaviours are grouped together. Not sure if that complies to the guidelines, but it certainly seems better

Copy link
Member

Choose a reason for hiding this comment

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

Great!

Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

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

Thanks @KianShah, lgtm

@phofl phofl merged commit 27135a5 into pandas-dev:main Jun 24, 2022
@phofl phofl added this to the 1.5 milestone Jun 24, 2022
@phofl
Copy link
Member

phofl commented Jun 24, 2022

thx @KianShah

@KianShah KianShah deleted the fix_error_msg branch June 25, 2022 04:55
yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
…ovided (pandas-dev#47451)

* Fixed error message

* Update v1.4.3.rst

* Update v1.4.3.rst

* Added test case

* Added test

* Fix rst file

* Fix black issues

* Fixed error msg and corresponding test

* improved changelog

* Also fix python docstring for :func:to_dict

* Fix failing test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Constructors Series/DataFrame/Index/pd.array Constructors Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Wrong error message output for pd.DataFrame.from_dict
3 participants