File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,9 @@ def f_1(grp):
132
132
133
133
result = df .groupby ("A" ).apply (f_1 )[["B" ]]
134
134
e = expected .copy ()
135
- e .loc ["Tiger" ] = np .nan
135
+ with tm .assert_produces_warning (FutureWarning , match = "item of incompatible dtype" ):
136
+ # TODO is this right? Should it warn when setting new column?
137
+ e .loc ["Tiger" ] = np .nan
136
138
tm .assert_frame_equal (result , e )
137
139
138
140
def f_2 (grp ):
@@ -141,7 +143,8 @@ def f_2(grp):
141
143
return grp .iloc [0 ]
142
144
143
145
result = df .groupby ("A" ).apply (f_2 )[["B" ]]
144
- e = expected .copy ()
146
+ # Explicit cast to float to avoid implicit cast when setting nan
147
+ e = expected .copy ().astype ({"B" : "float" })
145
148
e .loc ["Pony" ] = np .nan
146
149
tm .assert_frame_equal (result , e )
147
150
You can’t perform that action at this time.
0 commit comments