Skip to content

Commit

Permalink
TST: Added test for pivot_table with int64 dtype and dropna parameter (
Browse files Browse the repository at this point in the history
…#60374)

* added tests for int64

* pre-commit changes

* used pytest.mark.parametrize for expected_dtype
  • Loading branch information
AbhishekChaudharii authored Nov 21, 2024
1 parent 72bd17c commit f363721
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pandas/tests/reshape/test_pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2376,17 +2376,21 @@ def test_pivot_table_with_margins_and_numeric_columns(self):

tm.assert_frame_equal(result, expected)

def test_pivot_ea_dtype_dropna(self, dropna):
@pytest.mark.parametrize(
"dtype,expected_dtype", [("Int64", "Float64"), ("int64", "float64")]
)
def test_pivot_ea_dtype_dropna(self, dropna, dtype, expected_dtype):
# GH#47477
df = DataFrame({"x": "a", "y": "b", "age": Series([20, 40], dtype="Int64")})
# GH#47971
df = DataFrame({"x": "a", "y": "b", "age": Series([20, 40], dtype=dtype)})
result = df.pivot_table(
index="x", columns="y", values="age", aggfunc="mean", dropna=dropna
)
expected = DataFrame(
[[30]],
index=Index(["a"], name="x"),
columns=Index(["b"], name="y"),
dtype="Float64",
dtype=expected_dtype,
)
tm.assert_frame_equal(result, expected)

Expand Down

0 comments on commit f363721

Please sign in to comment.