-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CI Failing - Linux py37_np_dev - test_constructor_list_frames #32289
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
Comments
Looks like this build isn't available anymore. Happy to reopen if we continue to see this issue |
I'll leave this open since #32284 didn't fix the underlying issue. tests were skipped. |
this occured in 1.19.0rc1 (xref #34239) and tests are skipped again for 1.20.0.dev This may become an issue shortly |
Here's the root cause
I think we should consider deprecating passing a list of DataFrame to the DataFrame constructor. We don't allow passing a list of 2D ndarrays, so we likely shouldn't allow passing a list of 2d DataFrames? |
+1 on deprecating passing list of 2D things to the constructor. |
Nested DataFrames in general do still work, just not this method of creating them:
As noted above, it seems to happen because numpy.array now returns a 3D array that stacks the DataFrames, instead of a 1D array of objects. The two failing tests were introduced in #3243 and #5324. We don't document anywhere obvious that nested DataFrames are supposed to work, but #5324 was reported by an actual user of this. These two are not the only tests marked _is_numpy_dev, but are the only tests that fail with numpy 1.19 in Debian experimental's pandas 1.0. The exception message it raises (pandas/core/internals/construction.py:324) could be changed to add a note about this issue. |
This is failing the macpython builds now.
|
Looking at this again, I think we just remove the test, and perhaps add a whatsnew saying that because of upstream changes to NumPy this isn't supported anymore. DataFrame's are now consistently treated as 2D objects by NumPy, so we can't pretend that they're 1D in the constructor like we were. old behavior In [28]: np.__version__
Out[28]: '1.18.5'
In [29]: a = np.ones((0, 0))
In [30]: b = pd.DataFrame()
In [31]: np.array([a]).shape
Out[31]: (1, 0, 0)
In [32]: np.array([b]).shape
Out[32]: (1, 0)
In [33]: pd.DataFrame([a])
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-33-49139b5fa086> in <module>
----> 1 pd.DataFrame([a])
~/miniconda3/envs/pandas=1.0.4/lib/python3.8/site-packages/pandas/core/frame.py in __init__(self, data, index, columns, dtype, copy)
486 mgr = arrays_to_mgr(arrays, columns, index, columns, dtype=dtype)
487 else:
--> 488 mgr = init_ndarray(data, index, columns, dtype=dtype, copy=copy)
489 else:
490 mgr = init_dict({}, index, columns, dtype=dtype)
~/miniconda3/envs/pandas=1.0.4/lib/python3.8/site-packages/pandas/core/internals/construction.py in init_ndarray(values, index, columns, dtype, copy)
167 # by definition an array here
168 # the dtypes will be coerced to a single dtype
--> 169 values = prep_ndarray(values, copy=copy)
170
171 if dtype is not None:
~/miniconda3/envs/pandas=1.0.4/lib/python3.8/site-packages/pandas/core/internals/construction.py in prep_ndarray(values, copy)
293 values = values.reshape((values.shape[0], 1))
294 elif values.ndim != 2:
--> 295 raise ValueError("Must pass 2-d input")
296
297 return values
ValueError: Must pass 2-d input
In [34]: pd.DataFrame([b])
Out[34]:
Empty DataFrame
Columns: []
Index: [0] New behavior In [4]: a = np.ones((0, 0))
In [5]: b = pd.DataFrame()
In [6]: np.array([a]).shape
Out[6]: (1, 0, 0)
In [7]: np.array([b]).shape
Out[7]: (1, 0, 0)
In [8]: pd.DataFrame([a])
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-8-49139b5fa086> in <module>
----> 1 pd.DataFrame([a])
~/sandbox/pandas/pandas/core/frame.py in __init__(self, data, index, columns, dtype, copy)
513 mgr = arrays_to_mgr(arrays, columns, index, columns, dtype=dtype)
514 else:
--> 515 mgr = init_ndarray(data, index, columns, dtype=dtype, copy=copy)
516 else:
517 mgr = init_dict({}, index, columns, dtype=dtype)
~/sandbox/pandas/pandas/core/internals/construction.py in init_ndarray(values, index, columns, dtype, copy)
188 # by definition an array here
189 # the dtypes will be coerced to a single dtype
--> 190 values = _prep_ndarray(values, copy=copy)
191
192 if dtype is not None:
~/sandbox/pandas/pandas/core/internals/construction.py in _prep_ndarray(values, copy)
322 values = values.reshape((values.shape[0], 1))
323 elif values.ndim != 2:
--> 324 raise ValueError(f"Must pass 2-d input. shape={values.shape}")
325
326 return values
ValueError: Must pass 2-d input. shape=(1, 0, 0)
In [9]: pd.DataFrame([b])
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-9-338077bdea83> in <module>
----> 1 pd.DataFrame([b])
~/sandbox/pandas/pandas/core/frame.py in __init__(self, data, index, columns, dtype, copy)
513 mgr = arrays_to_mgr(arrays, columns, index, columns, dtype=dtype)
514 else:
--> 515 mgr = init_ndarray(data, index, columns, dtype=dtype, copy=copy)
516 else:
517 mgr = init_dict({}, index, columns, dtype=dtype)
~/sandbox/pandas/pandas/core/internals/construction.py in init_ndarray(values, index, columns, dtype, copy)
188 # by definition an array here
189 # the dtypes will be coerced to a single dtype
--> 190 values = _prep_ndarray(values, copy=copy)
191
192 if dtype is not None:
~/sandbox/pandas/pandas/core/internals/construction.py in _prep_ndarray(values, copy)
322 values = values.reshape((values.shape[0], 1))
323 elif values.ndim != 2:
--> 324 raise ValueError(f"Must pass 2-d input. shape={values.shape}")
325
326 return values
ValueError: Must pass 2-d input. shape=(1, 0, 0) |
* DOC/TST: DataFrame constructor with a list of DataFrames Closes #32289
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 Forwarded: no Gbp-Pq: Name numpy119_compat.patch
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 Forwarded: no Gbp-Pq: Name numpy119_compat.patch
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
https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=29531&view=logs&j=3a03f79d-0b41-5610-1aa4-b4a014d0bc70&t=4d05ed0e-1ed3-5bff-dd63-1e957f2766a9
The text was updated successfully, but these errors were encountered: