-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TST: Add testing to df.where() typecasting as per GH 42295 #43173
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 @maximilianaccardo! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-08-26 01:52:01 UTC |
result = d1.where(pd.notnull(d1), None).dtypes | ||
# make sure dtypes don't change | ||
expected = d1.dtypes | ||
tm.assert_series_equal(expected, result) |
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.
Instead of comparing the .dtype
results. Could you compare the DataFrame
result of result of d1.where(pd.notnull(d1), None)
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.
Yes, thanks for the review. I updated it.
def test_where_columns_casting(): | ||
# GH 42295 | ||
|
||
d1 = DataFrame({"a": [1.0, 2.0], "b": [3, np.nan]}) |
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.
Please call df for consistency and create expected = df.copy() before applying where
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.
Please create expected before calling where.
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 remove the comment, but lgtm
cc @mroeschke
Thanks @maximilianaccardo. Happy to have you tackle more issues that require tests. |
…v#43173) * Add testing to df.where() typecasting as per GH 42295 * Fix style * Directly compare data frames * Fix pre-commit * Rename dataframe to df * create expected before calling where Co-authored-by: Maximilian Carr <[email protected]> Co-authored-by: Maximilian Carr <[email protected]>
This makes sure that df.where does not cast floats to integers.