Skip to content

TST: Adding to_dict numeric consistency test (#22620) #29338

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 4 commits into from
Nov 5, 2019

Conversation

sofiane87
Copy link
Contributor

@sofiane87 sofiane87 commented Nov 2, 2019

@simonjayhawkins simonjayhawkins added the Testing pandas testing functions or related to the test suite label Nov 2, 2019
@jreback jreback added this to the 1.0 milestone Nov 2, 2019
# Expected Dtypes
expected = {"a": int, "b": float, "c": str}
# Extracting dtypes out of to_dict operation
df_dict = df.to_dict("records")[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

can you compare the entire result, not just the first record

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is now done

"b": type(df_dict["b"]),
"c": type(df_dict["c"]),
}
assert result == expected
Copy link
Member

Choose a reason for hiding this comment

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

I would check that the result of df.dtypes is correct. That would be simpler than this for-loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the point is to check that the type returned from to_dict are the same as the ones within the dataset. I am not sure how to do that using df.dtypes. @simonjayhawkins recommended that I make the tests as explicit as possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

actually this is ok

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah this is enough here

@jreback jreback merged commit 11e60d7 into pandas-dev:master Nov 5, 2019
@jreback
Copy link
Contributor

jreback commented Nov 5, 2019

this is good, thanks @sofiane87

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataFrame.to_dict(orient='records') numeric inconsistency
4 participants