-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Add tests in methods.py #23261
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
Add tests in methods.py #23261
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
75d9304
Add tests in methods.py
thoo 4a82fd7
Add more tests
thoo dad9d27
Flake8 error
thoo 1884b53
remove data_for_fillna and add series tests
thoo 7ab9458
"Switch to data_missing|fix json/decimal test er"
thoo 0a9fe11
Add fillna mismatched array length tests.
thoo c859b4d
overwrite tests for sparse array
thoo 9c55787
update as recommended
thoo 3760dce
Merge remote-tracking branch 'repo_org/master' into Add_ExtensionArra…
thoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,31 @@ def test_factorize_equivalence(self, data_for_grouping, na_sentinel): | |
tm.assert_numpy_array_equal(l1, l2) | ||
self.assert_extension_array_equal(u1, u2) | ||
|
||
def test_fillna_copy_frame(self, data_missing): | ||
arr = data_missing.take([1, 1]) | ||
df = pd.DataFrame({"A": arr}) | ||
|
||
filled_val = df.iloc[0, 0] | ||
result = df.fillna(filled_val) | ||
|
||
assert df.values.base is not result.values.base | ||
assert df.A._values is arr | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be removed I think. That's asserting something different. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! Thanks. |
||
|
||
def test_fillna_copy_series(self, data_missing): | ||
arr = data_missing.take([1, 1]) | ||
ser = pd.Series(arr) | ||
|
||
filled_val = ser[0] | ||
result = ser.fillna(filled_val) | ||
|
||
assert ser._values is not result._values | ||
assert ser._values is arr | ||
|
||
def test_fillna_length_mismatch(self, data_missing): | ||
with (tm.assert_raises_regex(ValueError, | ||
"Length of 'value' does not match.")): | ||
data_missing.fillna(data_missing.take([1])) | ||
|
||
def test_combine_le(self, data_repeated): | ||
# GH 20825 | ||
# Test that combine works when doing a <= (le) comparison | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't think this is correct. I believe that for DataFrames with EAs,
df.values
will all return a new ndarray, so this would be impossible to fail.Rather, I think the best we can do is
assert df.A.values is not result.A.values
.