Skip to content

Commit b970ceb

Browse files
authored
TST: Add test to verify 'dropna' behaviour on SparseArray (#34879)
1 parent e11ba01 commit b970ceb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/tests/arrays/sparse/test_array.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,3 +1295,15 @@ def test_map_missing():
12951295

12961296
result = arr.map({0: 10, 1: 11})
12971297
tm.assert_sp_array_equal(result, expected)
1298+
1299+
1300+
@pytest.mark.parametrize("fill_value", [np.nan, 1])
1301+
def test_dropna(fill_value):
1302+
# GH-28287
1303+
arr = SparseArray([np.nan, 1], fill_value=fill_value)
1304+
exp = SparseArray([1.0], fill_value=fill_value)
1305+
tm.assert_sp_array_equal(arr.dropna(), exp)
1306+
1307+
df = pd.DataFrame({"a": [0, 1], "b": arr})
1308+
expected_df = pd.DataFrame({"a": [1], "b": exp}, index=pd.Int64Index([1]))
1309+
tm.assert_equal(df.dropna(), expected_df)

0 commit comments

Comments
 (0)