-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
TST: GH28813 test .diff() on Sparse dtype #34268
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
@@ -36,6 +36,14 @@ def test_diff(self, datetime_frame): | |||
).astype("float64") | |||
tm.assert_frame_equal(result, expected) | |||
|
|||
# Result should be the same for sparse df, see GH28813 |
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.
Let's make a separate testing function for this test
normal = pd.DataFrame(arr) | ||
sparse = pd.DataFrame(arr, dtype='Sparse[int]') | ||
# we don't check dtype because one is sparse and the other isn't | ||
tm.assert_frame_equal(normal.diff(), sparse.diff(), check_dtype=False) |
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.
Ideally we want to create the expected DataFrame with just the constructor:
result = sparse.diff()
expected = pd.DataFrame(...)
tm.assert_frame_equal(result, expected)
Gotcha ok. Updated the PR with your fixes |
Thanks @matteosantama |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Add a quick test to confirm that .diff() function handles sparse dataframes the same way as regular dataframes.
First time making a pandas PR so comments, advice, critiques are encouraged.