@@ -46,7 +46,7 @@ def test_setitem_ndarray_1d(self):
46
46
df ["bar" ] = np .zeros (10 , dtype = complex )
47
47
48
48
# invalid
49
- msg = "Must have equal len keys and value when setting with an iterable"
49
+ msg = "Length mismatch when setting Dataframe with an iterable"
50
50
with pytest .raises (ValueError , match = msg ):
51
51
df .loc [df .index [2 :5 ], "bar" ] = np .array ([2.33j , 1.23 + 0.1j , 2.2 , 1.0 ])
52
52
@@ -67,7 +67,7 @@ def test_setitem_ndarray_1d_2(self):
67
67
df ["foo" ] = np .zeros (10 , dtype = np .float64 )
68
68
df ["bar" ] = np .zeros (10 , dtype = complex )
69
69
70
- msg = "Must have equal len keys and value when setting with an iterable"
70
+ msg = "Length mismatch when setting Dataframe with an iterable"
71
71
with pytest .raises (ValueError , match = msg ):
72
72
df [2 :5 ] = np .arange (1 , 4 ) * 1j
73
73
@@ -1036,7 +1036,7 @@ def test_scalar_setitem_with_nested_value(value):
1036
1036
df = DataFrame ({"A" : [1 , 2 , 3 ]})
1037
1037
msg = "|" .join (
1038
1038
[
1039
- "Must have equal len keys and value " ,
1039
+ "Length mismatch when setting Dataframe with an iterable " ,
1040
1040
"setting an array element with a sequence" ,
1041
1041
]
1042
1042
)
@@ -1046,7 +1046,9 @@ def test_scalar_setitem_with_nested_value(value):
1046
1046
# TODO For object dtype this happens as well, but should we rather preserve
1047
1047
# the nested data and set as such?
1048
1048
df = DataFrame ({"A" : [1 , 2 , 3 ], "B" : np .array ([1 , "a" , "b" ], dtype = object )})
1049
- with pytest .raises (ValueError , match = "Must have equal len keys and value" ):
1049
+ with pytest .raises (
1050
+ ValueError , match = "Length mismatch when setting Dataframe with an iterable"
1051
+ ):
1050
1052
df .loc [0 , "B" ] = value
1051
1053
# if isinstance(value, np.ndarray):
1052
1054
# assert (df.loc[0, "B"] == value).all()
0 commit comments