Skip to content

Commit e0b4e4c

Browse files
GH1089 Fix pandas nightly with new warnings on copy
1 parent 6db30fc commit e0b4e4c

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

tests/test_frame.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3996,8 +3996,9 @@ def test_hashable_args() -> None:
39963996
df.columns = ["test"] # type: ignore[assignment]
39973997

39983998
testDict = {"test": 1}
3999-
df.to_string("test", col_space=testDict)
4000-
df.to_string("test", col_space={"test": 1})
3999+
with ensure_clean() as path:
4000+
df.to_string(path, col_space=testDict)
4001+
df.to_string(path, col_space={"test": 1})
40014002

40024003

40034004
# GH 906
@@ -4009,7 +4010,19 @@ def test_transpose() -> None:
40094010
df = pd.DataFrame({"a": [1, 1, 2], "b": [4, 5, 6]})
40104011
check(assert_type(df.transpose(), pd.DataFrame), pd.DataFrame)
40114012
check(assert_type(df.transpose(None), pd.DataFrame), pd.DataFrame)
4012-
check(assert_type(df.transpose(copy=True), pd.DataFrame), pd.DataFrame)
4013+
4014+
msg = (
4015+
r"The copy keyword is deprecated and will be removed in a future version\. Copy"
4016+
r"-on-Write is active in pandas since 3\.0 which utilizes a lazy copy mechanism"
4017+
r" that defers copies until necessary\. Use \.copy\(\) to make an eager copy if"
4018+
" necessary.*"
4019+
)
4020+
with pytest_warns_bounded(
4021+
DeprecationWarning,
4022+
msg,
4023+
lower="2.2.99",
4024+
):
4025+
check(assert_type(df.transpose(copy=True), pd.DataFrame), pd.DataFrame)
40134026

40144027

40154028
def test_combine() -> None:

tests/test_series.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3714,6 +3714,19 @@ def test_align() -> None:
37143714
aligned_s0, aligned_s1 = s0.align(s1)
37153715
check(assert_type(aligned_s0, pd.Series), pd.Series)
37163716
check(assert_type(aligned_s1, pd.Series), pd.Series)
3717-
aligned_s0, aligned_s1 = s0.align(s1, fill_value=0, axis=0, level=0, copy=False)
3717+
3718+
msg = (
3719+
r"The copy keyword is deprecated and will be removed in a future version\. Copy"
3720+
r"-on-Write is active in pandas since 3\.0 which utilizes a lazy copy mechanism"
3721+
r" that defers copies until necessary\. Use \.copy\(\) to make an eager copy if"
3722+
" necessary.*"
3723+
)
3724+
with pytest_warns_bounded(
3725+
DeprecationWarning,
3726+
msg,
3727+
lower="2.2.99",
3728+
):
3729+
aligned_s0, aligned_s1 = s0.align(s1, fill_value=0, axis=0, level=0, copy=False)
3730+
37183731
check(assert_type(aligned_s0, pd.Series), pd.Series)
37193732
check(assert_type(aligned_s1, pd.Series), pd.Series)

0 commit comments

Comments
 (0)