Skip to content

Commit 8391b44

Browse files
committed
add test for issue pandas-dev#29563
1 parent b9f26e2 commit 8391b44

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/series/indexing/test_loc.py

+14
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,17 @@ def test_basic_setitem_with_labels(datetime_series):
157157
s2["a"] = expected
158158
result = s2["a"]
159159
assert result == expected
160+
161+
# test for issue https://github.com/pandas-dev/pandas/issues/29563
162+
def indexing_work_after_changing_Serie_SparseDType():
163+
164+
fill_value = 0
165+
166+
s = pd.Series([fill_value])
167+
tm.assert_series_equal(s, s.loc[[fill_value]])
168+
dtype = pd.SparseDtype("float", fill_value=fill_value)
169+
s = s.astype(dtype)
170+
171+
# s[[fill_value]] calls s.loc so this almoast the same test
172+
tm.assert_series_equal(s, s.loc[[fill_value]])
173+
tm.assert_series_equal(s, s[[fill_value]])

0 commit comments

Comments
 (0)