We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 25f0693 commit 0e5fb73Copy full SHA for 0e5fb73
pandas/tests/groupby/test_groupby.py
@@ -132,7 +132,9 @@ def f_1(grp):
132
133
result = df.groupby("A").apply(f_1)[["B"]]
134
e = expected.copy()
135
- e.loc["Tiger"] = np.nan
+ 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
138
tm.assert_frame_equal(result, e)
139
140
def f_2(grp):
@@ -141,7 +143,8 @@ def f_2(grp):
141
143
return grp.iloc[0]
142
144
145
result = df.groupby("A").apply(f_2)[["B"]]
- e = expected.copy()
146
+ # Explicit cast to float to avoid implicit cast when setting nan
147
+ e = expected.copy().astype({"B": "float"})
148
e.loc["Pony"] = np.nan
149
150
0 commit comments