Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pandas/tests/frame/methods/test_describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,9 @@ def test_ea_with_na(self, any_numeric_ea_dtype):
# GH#48778

df = DataFrame({"a": [1, pd.NA, pd.NA], "b": pd.NA}, dtype=any_numeric_ea_dtype)
result = df.describe()
# Warning from numpy for taking std of single element
with tm.assert_produces_warning(RuntimeWarning, check_stacklevel=False):
result = df.describe()
expected = DataFrame(
{"a": [1.0, 1.0, pd.NA] + [1.0] * 5, "b": [0.0] + [pd.NA] * 7},
index=["count", "mean", "std", "min", "25%", "50%", "75%", "max"],
Expand Down
14 changes: 14 additions & 0 deletions pandas/tests/frame/methods/test_shift.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,13 @@ def test_shift_axis1_multiple_blocks(self, using_array_manager):
result = df3.shift(2, axis=1)

expected = df3.take([-1, -1, 0, 1, 2], axis=1)
# Explicit cast to float to avoid implicit cast when setting nan.
# Column names aren't unique, so directly calling `expected.astype` won't work.
expected = expected.pipe(
lambda df: df.set_axis(range(df.shape[1]), axis=1)
.astype({0: "float", 1: "float"})
.set_axis(df.columns, axis=1)
)
expected.iloc[:, :2] = np.nan
expected.columns = df3.columns

Expand All @@ -410,6 +417,13 @@ def test_shift_axis1_multiple_blocks(self, using_array_manager):
result = df3.shift(-2, axis=1)

expected = df3.take([2, 3, 4, -1, -1], axis=1)
# Explicit cast to float to avoid implicit cast when setting nan.
# Column names aren't unique, so directly calling `expected.astype` won't work.
expected = expected.pipe(
lambda df: df.set_axis(range(df.shape[1]), axis=1)
.astype({3: "float", 4: "float"})
.set_axis(df.columns, axis=1)
)
expected.iloc[:, -2:] = np.nan
expected.columns = df3.columns

Expand Down