Skip to content

Commit f363721

Browse files
TST: Added test for pivot_table with int64 dtype and dropna parameter (#60374)
* added tests for int64 * pre-commit changes * used pytest.mark.parametrize for expected_dtype
1 parent 72bd17c commit f363721

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pandas/tests/reshape/test_pivot.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -2376,17 +2376,21 @@ def test_pivot_table_with_margins_and_numeric_columns(self):
23762376

23772377
tm.assert_frame_equal(result, expected)
23782378

2379-
def test_pivot_ea_dtype_dropna(self, dropna):
2379+
@pytest.mark.parametrize(
2380+
"dtype,expected_dtype", [("Int64", "Float64"), ("int64", "float64")]
2381+
)
2382+
def test_pivot_ea_dtype_dropna(self, dropna, dtype, expected_dtype):
23802383
# GH#47477
2381-
df = DataFrame({"x": "a", "y": "b", "age": Series([20, 40], dtype="Int64")})
2384+
# GH#47971
2385+
df = DataFrame({"x": "a", "y": "b", "age": Series([20, 40], dtype=dtype)})
23822386
result = df.pivot_table(
23832387
index="x", columns="y", values="age", aggfunc="mean", dropna=dropna
23842388
)
23852389
expected = DataFrame(
23862390
[[30]],
23872391
index=Index(["a"], name="x"),
23882392
columns=Index(["b"], name="y"),
2389-
dtype="Float64",
2393+
dtype=expected_dtype,
23902394
)
23912395
tm.assert_frame_equal(result, expected)
23922396

0 commit comments

Comments
 (0)