File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
pandas/tests/series/indexing Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -391,6 +391,19 @@ def test_setslice(datetime_series):
391
391
assert sl .index .is_unique is True
392
392
393
393
394
+ def test_incorrect_assigment ():
395
+ x = np .random .randn (2 , 2 )
396
+ y = pd .Series (range (2 ))
397
+
398
+ msg = r"shape mismatch: value array of shape \(2,2\) could not be broadcast to indexing result of shape \(2,\)"
399
+ with pytest .raises (ValueError , match = msg ):
400
+ y .loc [range (2 )] = x
401
+
402
+ msg = r"could not broadcast input array from shape \(2,2\) into shape \(2\)"
403
+ with pytest .raises (ValueError , match = msg ):
404
+ y .loc [:] = x
405
+
406
+
394
407
# FutureWarning from NumPy about [slice(None, 5).
395
408
@pytest .mark .filterwarnings ("ignore:Using a non-tuple:FutureWarning" )
396
409
def test_basic_getitem_setitem_corner (datetime_series ):
You can’t perform that action at this time.
0 commit comments