Skip to content

Commit 0e5fb73

Browse files
author
MarcoGorelli
committed
fixup test_groupby
1 parent 25f0693 commit 0e5fb73

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pandas/tests/groupby/test_groupby.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ def f_1(grp):
132132

133133
result = df.groupby("A").apply(f_1)[["B"]]
134134
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
136138
tm.assert_frame_equal(result, e)
137139

138140
def f_2(grp):
@@ -141,7 +143,8 @@ def f_2(grp):
141143
return grp.iloc[0]
142144

143145
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"})
145148
e.loc["Pony"] = np.nan
146149
tm.assert_frame_equal(result, e)
147150

0 commit comments

Comments
 (0)