Skip to content

Commit 431a2f0

Browse files
committed
TST: add regression test for DataFrame.mean(axis=1) with nullable Int64 dtype (GH#36585)
1 parent 2f26644 commit 431a2f0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pandas/tests/frame/test_reductions.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,3 +2170,22 @@ def test_numeric_ea_axis_1(method, skipna, min_count, any_numeric_ea_dtype):
21702170
if method not in ("idxmax", "idxmin"):
21712171
expected = expected.astype(expected_dtype)
21722172
tm.assert_series_equal(result, expected)
2173+
2174+
def test_mean_nullable_int_axis_1():
2175+
"""
2176+
Test DataFrame.mean(axis=1) with nullable Int64 dtype.
2177+
2178+
Ensures correct results with skipna=True and skipna=False.
2179+
"""
2180+
df = pd.DataFrame({
2181+
"a": [1, 2, 3, 4],
2182+
"b": pd.Series([1, 2, 4, None], dtype=pd.Int64Dtype())
2183+
})
2184+
2185+
result = df.mean(axis=1, skipna=True)
2186+
expected = pd.Series([1.0, 2.0, 3.5, 4.0], dtype="Float64")
2187+
pd.testing.assert_series_equal(result, expected)
2188+
2189+
result = df.mean(axis=1, skipna=False)
2190+
expected = pd.Series([1.0, 2.0, 3.5, pd.NA], dtype="Float64")
2191+
pd.testing.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)