Skip to content

Commit d2e2e3e

Browse files
committed
fixup! BUG: repr SparseDataFrame after setting a value
1 parent 23e5f38 commit d2e2e3e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

pandas/tests/sparse/test_format.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,11 @@ def test_sparse_frame(self):
120120
def test_sparse_repr_after_set(self):
121121
# GH 15488
122122
sdf = pd.SparseDataFrame(index=[0, 1], columns=[0, 1])
123+
res = sdf.copy()
123124

124125
# Ignore the warning
125-
old_opt = pd.core.config.get_option('mode.chained_assignment')
126-
pd.core.config.set_option('mode.chained_assignment', None)
127-
sdf[0][0] = 1 # This line triggers the bug
128-
try:
129-
repr(sdf)
130-
finally:
131-
pd.core.config.set_option('mode.chained_assignment', old_opt)
126+
with pd.option_context('mode.chained_assignment', None):
127+
sdf[0][0] = 1 # This line triggers the bug
128+
129+
repr(sdf)
130+
tm.assert_sp_frame_equal(sdf, res)

0 commit comments

Comments
 (0)