-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST:add test for df replace GH34871 #34904
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
TST:add test for df replace GH34871 #34904
Conversation
test now does not check for actual equality between original and new dataframe anymore, this behavior needs treduce test to only fail for exception test now does not check for actual equality between original and new dataframe anymore, this behavior needs to be addressed in another bug fix be addressed in another bug fix
don't reference old version assert expected result
|
||
df_expected_result = pd.DataFrame({"Per": [pd.Period("2020-01")] * 3}) | ||
# currently replace() changes dtype from Period to object | ||
df_expected_result["Per"] = df_expected_result["Per"].astype(object) |
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.
so this is wrong, we want to xfail this test, this should not change the dtype, pls add the issue number in the xfail itself
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.
meaning, yes it doesn't raise an expection, but the output is still converted to object
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.
gotcha, thanks for teaching me about xfail. i changed the test to now expect the result we would like to see from replace() in the future, and to xfail for now.
unit test for replace() now checks whether the dataframe returned is equal to how we want the function to behave, i.e. no changes to either data values or data type. this behavior needs to be implemented in the future, thux xfail-ing for now.
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
add tiny regression test for not failing on calling df.replace() with Period column
working on this revealed other quirks of df.replace(): it now does not raise an exception anymore, and the dataframe returned by replace() has the right values. However, the dtype of a Period column changes to Object, which is surprising.
I've added the observations to GH34871