|
11 | 11 | import pytz
|
12 | 12 |
|
13 | 13 | from pandas.compat import PY37, is_platform_little_endian
|
14 |
| -from pandas.compat.numpy import _is_numpy_dev |
| 14 | +from pandas.compat.numpy import _np_version_under1p20 |
15 | 15 |
|
16 | 16 | from pandas.core.dtypes.common import is_integer_dtype
|
17 | 17 |
|
@@ -147,14 +147,20 @@ def test_constructor_dtype_list_data(self):
|
147 | 147 | assert df.loc[1, 0] is None
|
148 | 148 | assert df.loc[0, 1] == "2"
|
149 | 149 |
|
150 |
| - @pytest.mark.xfail(_is_numpy_dev, reason="Interprets list of frame as 3D") |
151 |
| - def test_constructor_list_frames(self): |
152 |
| - # see gh-3243 |
153 |
| - result = DataFrame([DataFrame()]) |
154 |
| - assert result.shape == (1, 0) |
| 150 | + @pytest.mark.skipif(_np_version_under1p20, reason="NumPy change.") |
| 151 | + def test_constructor_list_of_2d_raises(self): |
| 152 | + # https://github.com/pandas-dev/pandas/issues/32289 |
| 153 | + a = pd.DataFrame() |
| 154 | + b = np.empty((0, 0)) |
| 155 | + with pytest.raises(ValueError, match=r"shape=\(1, 0, 0\)"): |
| 156 | + pd.DataFrame([a]) |
155 | 157 |
|
156 |
| - result = DataFrame([DataFrame(dict(A=np.arange(5)))]) |
157 |
| - assert isinstance(result.iloc[0, 0], DataFrame) |
| 158 | + with pytest.raises(ValueError, match=r"shape=\(1, 0, 0\)"): |
| 159 | + pd.DataFrame([b]) |
| 160 | + |
| 161 | + a = pd.DataFrame({"A": [1, 2]}) |
| 162 | + with pytest.raises(ValueError, match=r"shape=\(2, 2, 1\)"): |
| 163 | + pd.DataFrame([a, a]) |
158 | 164 |
|
159 | 165 | def test_constructor_mixed_dtypes(self):
|
160 | 166 | def _make_mixed_dtypes_df(typ, ad=None):
|
@@ -507,22 +513,6 @@ def test_constructor_error_msgs(self):
|
507 | 513 | with pytest.raises(ValueError, match=msg):
|
508 | 514 | DataFrame({"a": False, "b": True})
|
509 | 515 |
|
510 |
| - @pytest.mark.xfail(_is_numpy_dev, reason="Interprets embedded frame as 3D") |
511 |
| - def test_constructor_with_embedded_frames(self): |
512 |
| - |
513 |
| - # embedded data frames |
514 |
| - df1 = DataFrame({"a": [1, 2, 3], "b": [3, 4, 5]}) |
515 |
| - df2 = DataFrame([df1, df1 + 10]) |
516 |
| - |
517 |
| - df2.dtypes |
518 |
| - str(df2) |
519 |
| - |
520 |
| - result = df2.loc[0, 0] |
521 |
| - tm.assert_frame_equal(result, df1) |
522 |
| - |
523 |
| - result = df2.loc[1, 0] |
524 |
| - tm.assert_frame_equal(result, df1 + 10) |
525 |
| - |
526 | 516 | def test_constructor_subclass_dict(self, float_frame, dict_subclass):
|
527 | 517 | # Test for passing dict subclass to constructor
|
528 | 518 | data = {
|
|
0 commit comments