-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DEPR: fix stacklevel for DataFrame(mgr) deprecation #55591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
81b2e47
2ff11b3
0ab9c6a
864115f
4c15c48
bdebc9f
20dabc5
ea2bf91
7882d60
54a8591
9042d97
0bebb2c
172bd88
04ac100
ece6c50
017f8d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,10 @@ | |
import pandas as pd | ||
import pandas._testing as tm | ||
|
||
pytestmark = pytest.mark.filterwarnings( | ||
"ignore:Passing a BlockManager to DataFrame:DeprecationWarning" | ||
) | ||
|
||
pa = pytest.importorskip("pyarrow", minversion="1.0.1") | ||
|
||
from pandas.core.arrays.arrow._arrow_utils import pyarrow_array_to_numpy_and_mask | ||
|
@@ -36,9 +40,7 @@ def test_arrow_roundtrip(data): | |
table = pa.table(df) | ||
assert table.field("a").type == str(data.dtype.numpy_dtype) | ||
|
||
msg = "Passing a BlockManager to DataFrame is deprecated" | ||
with tm.assert_produces_warning(DeprecationWarning, match=msg): | ||
result = table.to_pandas() | ||
result = table.to_pandas() | ||
Comment on lines
-39
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In several of those cases I removed the warning assert, and added a general filterwarnings mark (at the test or top of the file), because 1) there is no need to "test" that the warning is raised in all those cases, and 2) once the PR to fix this on the pyarrow side is merged, all those cases will start failing anyway |
||
assert result["a"].dtype == data.dtype | ||
tm.assert_frame_equal(result, df) | ||
|
||
|
@@ -56,9 +58,7 @@ def types_mapper(arrow_type): | |
record_batch = pa.RecordBatch.from_arrays( | ||
[bools_array, ints_array, small_ints_array], ["bools", "ints", "small_ints"] | ||
) | ||
msg = "Passing a BlockManager to DataFrame is deprecated" | ||
with tm.assert_produces_warning(DeprecationWarning, match=msg): | ||
result = record_batch.to_pandas(types_mapper=types_mapper) | ||
result = record_batch.to_pandas(types_mapper=types_mapper) | ||
bools = pd.Series([True, None, False], dtype="boolean") | ||
ints = pd.Series([1, None, 2], dtype="Int64") | ||
small_ints = pd.Series([-1, 0, 7], dtype="Int64") | ||
|
@@ -75,9 +75,7 @@ def test_arrow_load_from_zero_chunks(data): | |
table = pa.table( | ||
[pa.chunked_array([], type=table.field("a").type)], schema=table.schema | ||
) | ||
msg = "Passing a BlockManager to DataFrame is deprecated" | ||
with tm.assert_produces_warning(DeprecationWarning, match=msg): | ||
result = table.to_pandas() | ||
result = table.to_pandas() | ||
assert result["a"].dtype == data.dtype | ||
tm.assert_frame_equal(result, df) | ||
|
||
|
@@ -98,18 +96,14 @@ def test_arrow_sliced(data): | |
|
||
df = pd.DataFrame({"a": data}) | ||
table = pa.table(df) | ||
msg = "Passing a BlockManager to DataFrame is deprecated" | ||
with tm.assert_produces_warning(DeprecationWarning, match=msg): | ||
result = table.slice(2, None).to_pandas() | ||
result = table.slice(2, None).to_pandas() | ||
expected = df.iloc[2:].reset_index(drop=True) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
# no missing values | ||
df2 = df.fillna(data[0]) | ||
table = pa.table(df2) | ||
msg = "Passing a BlockManager to DataFrame is deprecated" | ||
with tm.assert_produces_warning(DeprecationWarning, match=msg): | ||
result = table.slice(2, None).to_pandas() | ||
result = table.slice(2, None).to_pandas() | ||
expected = df2.iloc[2:].reset_index(drop=True) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Could you reference the anticipated pyarrow version that would have this fix (if the fix has already been made in pyarrow)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not yet fully sure. At least 15.0.0 I assume, but potentially a 14.0.x release as well. But will add 15.0 then.