Skip to content

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

Merged

Conversation

nwweber
Copy link
Contributor

@nwweber nwweber commented Jun 20, 2020

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

nwweber added 2 commits June 20, 2020 16:22
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
@jreback jreback added Period Period data type Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Jun 20, 2020
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)
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

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.
@jreback jreback added this to the 1.1 milestone Jun 24, 2020
@jreback jreback added the Testing pandas testing functions or related to the test suite label Jun 24, 2020
@jreback jreback merged commit 1237f20 into pandas-dev:master Jun 24, 2020
@jreback
Copy link
Contributor

jreback commented Jun 24, 2020

thanks @nwweber

happy for you to tackle #34871 :->

@nwweber
Copy link
Contributor Author

nwweber commented Jun 26, 2020

thanks @nwweber

happy for you to tackle #34871 :->

i'll have a look over the weekend :)

samc1213 added a commit to samc1213/pandas that referenced this pull request Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Period Period data type Reshaping Concat, Merge/Join, Stack/Unstack, Explode Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants