Skip to content

Commit 681af4c

Browse files
authored
TST: Test groupby for columns with string objects (#52757)
1 parent 84f3591 commit 681af4c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/groupby/test_groupby.py

+11
Original file line numberDiff line numberDiff line change
@@ -2970,3 +2970,14 @@ def test_groupby_numeric_only_std_no_result(numeric_only):
29702970
ValueError, match="could not convert string to float: 'bar'"
29712971
):
29722972
dfgb.std(numeric_only=numeric_only)
2973+
2974+
2975+
@pytest.mark.parametrize("bug_var", [1, "a"])
2976+
def test_groupby_sum_on_nan_should_return_nan(bug_var):
2977+
# GH 24196
2978+
df = DataFrame({"A": [bug_var, bug_var, bug_var, np.nan]})
2979+
dfgb = df.groupby(lambda x: x)
2980+
result = dfgb.sum(min_count=1)
2981+
2982+
expected_df = DataFrame([bug_var, bug_var, bug_var, np.nan], columns=["A"])
2983+
tm.assert_frame_equal(result, expected_df)

0 commit comments

Comments
 (0)