Skip to content

Commit 1073cb1

Browse files
Debian Science Teamrebecca-palmer
Debian Science Team
authored andcommitted
Don't fail with Numpy 1.19
Creating a nested DataFrame (which was already not recommended) via the constructor no longer works. Give a clearer error and xfail the tests. Author: Rebecca N. Palmer <[email protected]> Bug: pandas-dev/pandas#32289 Bug-Debian: https://bugs.debian.org/963817 Forwarded: no Gbp-Pq: Name numpy119_compat.patch
1 parent 87e47a4 commit 1073cb1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

pandas/core/internals/construction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def convert(v):
292292
if values.ndim == 1:
293293
values = values.reshape((values.shape[0], 1))
294294
elif values.ndim != 2:
295-
raise ValueError("Must pass 2-d input")
295+
raise ValueError("Plain DataFrames must be 2-d - for higher dimensions use MultiIndex or the python3-xarray package. If you are trying to create a nested DataFrame (which is not recommended) see https://github.com/pandas-dev/pandas/issues/32289")
296296

297297
return values
298298

pandas/tests/frame/test_constructors.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def test_constructor_dtype_list_data(self):
145145
assert df.loc[1, 0] is None
146146
assert df.loc[0, 1] == "2"
147147

148-
@pytest.mark.xfail(_is_numpy_dev, reason="Interprets list of frame as 3D")
148+
@pytest.mark.xfail(condition=True,strict=False,raises=ValueError, reason="Interprets list of frame as 3D, https://github.com/pandas-dev/pandas/issues/32289")
149149
def test_constructor_list_frames(self):
150150
# see gh-3243
151151
result = DataFrame([DataFrame()])
@@ -477,7 +477,7 @@ def test_constructor_error_msgs(self):
477477
DataFrame(index=[0], columns=range(0, 4), data=arr)
478478

479479
# higher dim raise exception
480-
with pytest.raises(ValueError, match="Must pass 2-d input"):
480+
with pytest.raises(ValueError, match="Plain DataFrames must be 2-d"):
481481
DataFrame(np.zeros((3, 3, 3)), columns=["A", "B", "C"], index=[1])
482482

483483
# wrong size axis labels
@@ -498,7 +498,7 @@ def test_constructor_error_msgs(self):
498498
with pytest.raises(ValueError, match=msg):
499499
DataFrame({"a": False, "b": True})
500500

501-
@pytest.mark.xfail(_is_numpy_dev, reason="Interprets embedded frame as 3D")
501+
@pytest.mark.xfail(condition=True,strict=False,raises=ValueError, reason="Interprets embedded frame as 3D, https://github.com/pandas-dev/pandas/issues/32289")
502502
def test_constructor_with_embedded_frames(self):
503503

504504
# embedded data frames
@@ -764,7 +764,7 @@ def _check_basic_constructor(self, empty):
764764
DataFrame(mat, columns=["A", "B"], index=[1, 2])
765765

766766
# higher dim raise exception
767-
with pytest.raises(ValueError, match="Must pass 2-d input"):
767+
with pytest.raises(ValueError, match="Plain DataFrames must be 2-d"):
768768
DataFrame(empty((3, 3, 3)), columns=["A", "B", "C"], index=[1])
769769

770770
# automatic labeling

0 commit comments

Comments
 (0)