-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
Fix nonzero of a SparseArray #21175
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
Fix nonzero of a SparseArray #21175
Changes from 10 commits
9da99bf 349b847 eb1c706 41f07f5 02dd63d 475eacf 9425a24 80fe5f3 29bba39 e53e3fd ccb0cfb e25366b 539e91f 1fa410c 95432d9 1961e04 165feae e70206e 400d8a0 19a3a42 ab63531 2c912f1 File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -1350,3 +1350,11 @@ def test_assign_with_sparse_frame(self): | |
| | ||
| for column in res.columns: | ||
| assert type(res[column]) is SparseSeries | ||
| | ||
| def test_dropna(self): | ||
| tm.assert_sp_frame_equal( | ||
| pd.SparseDataFrame({"F2": [0, 1]}), | ||
| pd.SparseDataFrame( | ||
| {"F1": [float('nan'), float('nan')], "F2": [0, 1]} | ||
| ).dropna(axis=1, inplace=False, how='all') | ||
| ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -455,6 +455,25 @@ def tests_indexing_with_sparse(self, kind, fill): | |
| s.iloc[indexer] | ||
| | ||
| | ||
| class TestSparseArray(object): | ||
| ||
| | ||
| def test_nonzero(self): | ||
| sa = pd.SparseArray([ | ||
| float('nan'), | ||
| float('nan'), | ||
| 1, 0, 0, | ||
| 2, 0, 0, 0, | ||
| 3, 0, 0 | ||
| ]) | ||
| tm.assert_numpy_array_equal(np.array([2, 5, 9], dtype=np.int32), | ||
| sa.nonzero()[0]) | ||
| | ||
| sa = pd.SparseArray( | ||
| [0, 0, 1, 0, 0, 2, 0, 0, 0, 3, 0, 0]) | ||
| tm.assert_numpy_array_equal(np.array([2, 5, 9], dtype=np.int32), | ||
| sa.nonzero()[0]) | ||
| | ||
| | ||
| class TestSparseSeriesMultiIndexing(TestSparseSeriesIndexing): | ||
| | ||
| def setup_method(self, method): | ||
| | ||
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.
use the result= and expected= format
add the issue number as a comment