We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
pytest pandas/tests/extension/test_sparse.py::TestGetitem::test_getitem_scalar --count=100 -x
Tat fails when the first value is sparse, the fill_value is int, but the .dtype.type is np.int64.
.dtype.type
np.int64
pytest pandas/tests/extension/test_sparse.py::TestMethods::test_unique --count=100 -x
That fails with the array is all sparse. Fixed by
diff --git a/pandas/core/sparse/array.py b/pandas/core/sparse/array.py index 15b5118db..17e2bd188 100644 --- a/pandas/core/sparse/array.py +++ b/pandas/core/sparse/array.py @@ -561,7 +561,7 @@ class SparseArray(PandasObject, ExtensionArray, ExtensionOpsMixin): return -1 indices = self.sp_index.to_int_index().indices - if indices[0] > 0: + if len(indices) == 0 or indices[0] > 0: return 0 diff = indices[1:] - indices[:-1] diff --git a/pandas/tests/sparse/test_array.py b/pandas/tests/sparse/test_array.py index 0257d9962..5b1afdc7a 100644 --- a/pandas/tests/sparse/test_array.py +++ b/pandas/tests/sparse/test_array.py @@ -1065,6 +1065,13 @@ def test_unique_na_fill(arr, fill_value): tm.assert_numpy_array_equal(a, b) +def test_unique_all_sparse(): + arr = SparseArray([0, 0]) + result = arr.unique() + expected = SparseArray([0]) + tm.assert_sp_array_equal(result, expected) + +
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Tat fails when the first value is sparse, the fill_value is int, but the
.dtype.type
isnp.int64
.That fails with the array is all sparse. Fixed by
The text was updated successfully, but these errors were encountered: