Skip to content

Commit e96495f

Browse files
add pytest
1 parent 99a81f9 commit e96495f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/tests/sparse/frame/test_frame.py

+9
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,15 @@ def test_constructor_ndarray(self, float_frame):
156156
SparseDataFrame(float_frame.values,
157157
columns=float_frame.columns[:-1])
158158

159+
def test_construct_unmatched_sparsedataframe(self, float_frame):
160+
# GH25484
161+
dates = pd.bdate_range('1/1/2011', periods=10)
162+
sp = SparseDataFrame(float_frame.values, index=dates)
163+
N = len(sp)
164+
msg = 'Length of values does not match length of index'
165+
with pytest.raises(ValueError, match=msg):
166+
sp['foo'] = np.random.randn(N-1)
167+
159168
# GH 9272
160169
def test_constructor_empty(self):
161170
sp = SparseDataFrame()

0 commit comments

Comments
 (0)