-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Fixes Incompatible return value type in pandas/core/generic.py #52897
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e2a7703
cast int
HappyHorse cb196f8
added masnan changes
HappyHorse 7a95ffc
install pre-commit
HappyHorse bce4731
added pytest testing for size int casting
HappyHorse 1670b57
new changes, removed pd
HappyHorse cda60c1
reformat
HappyHorse e94a338
removed git ignore, added comments to indicate new tests
HappyHorse d179d9e
removed ignore
HappyHorse 0bac984
entry sorted alphabetical
HappyHorse 5dbdfa7
Merge branch 'main' into generic-expected-int
bunardsheng 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
from pandas import DataFrame | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"data, index, expected", | ||
[ | ||
({"col1": [1], "col2": [3]}, None, 2), | ||
({}, None, 0), | ||
({"col1": [1, np.nan], "col2": [3, 4]}, None, 4), | ||
({"col1": [1, 2], "col2": [3, 4]}, [["a", "b"], [1, 2]], 4), | ||
({"col1": [1, 2, 3, 4], "col2": [3, 4, 5, 6]}, ["x", "y", "a", "b"], 8), | ||
], | ||
) | ||
def test_size(data, index, expected): | ||
# GH#52897 | ||
df = DataFrame(data, index=index) | ||
assert df.size == expected | ||
assert isinstance(df.size, int) |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import pytest | ||
|
||
from pandas import Series | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"data, index, expected", | ||
[ | ||
([1, 2, 3], None, 3), | ||
({"a": 1, "b": 2, "c": 3}, None, 3), | ||
([1, 2, 3], ["x", "y", "z"], 3), | ||
([1, 2, 3, 4, 5], ["x", "y", "z", "w", "n"], 5), | ||
([1, 2, 3], None, 3), | ||
([1, 2, 3], ["x", "y", "z"], 3), | ||
([1, 2, 3, 4], ["x", "y", "z", "w"], 4), | ||
], | ||
) | ||
def test_series(data, index, expected): | ||
# GH#52897 | ||
ser = Series(data, index=index) | ||
assert ser.size == expected | ||
assert isinstance(ser.size, int) |
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.
Uh oh!
There was an error while loading. Please reload this page.