You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File .venv/lib/python3.11/site-packages/pandas/core/internals/blocks.py:2253, in EABackedBlock.get_values(self, dtype)
[2251](.venv/lib/python3.11/site-packages/pandas/core/internals/blocks.py:2251) values = values.astype(object)
[2252](.venv/lib/python3.11/site-packages/pandas/core/internals/blocks.py:2252) # TODO(EA2D): reshape not needed with 2D EAs
-> [2253](.venv/lib/python3.11/site-packages/pandas/core/internals/blocks.py:2253) return np.asarray(values).reshape(self.shape)
ValueError: cannot reshape array of size 9 into shape
Issue Description
I'm not really knowledgeable on the internals of Pandas and array extensions, so I'm not sure if this is the right place to report the bug, but since it occurred in the Pandas core code, I came here first. Please let me know if this is actually an issue with the awkward or awkward_pandas module.
When calling iterrows() on a DataFrame which contains an awkward array as a column, a ValueError occurs (see stacktrace example). This error only occurs when all rows of the awkward array are of equal length. In this case the calls to values.astype(object) and/or np.asarray(values) in the get_values function in the pandas/core/internals/blocks.py module result in a 2D array, instead of a 1D array with nested lists.
When the awkward array is actually jagged, the call results in the correct format of the array (see commented line in code example) and iterrows() works as intended.
Expected Behavior
I would expect iterrows() to iterate over the DataFrame rows without throwing an error, but instead returning a Series with the value of the awkward array at the index of the row set correctly.
Installed Versions
INSTALLED VERSIONS
commit : d9cdd2e
python : 3.11.0.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.146.1-microsoft-standard-WSL2
Version : #1 SMP Thu Jan 11 04:09:03 UTC 2024
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
Thanks for the report! While this might be a problem with pandas, we don't know enough about awkward pandas to be able to debug this issue, it might be better to open this issue in awkward_pandas and see if the issue is actually on their end or our end.
Going to close, but if the people at awkward-pandas suggest the issue is actually on our end, feel free to re-open this issue and we can continue our discussion here.
A quick update for anyone who might come across this issue:
The developer of awkward_pandas replied to the issue I posted on their page as well. It seems this problem will be solved soon in a future release.
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
I'm not really knowledgeable on the internals of Pandas and array extensions, so I'm not sure if this is the right place to report the bug, but since it occurred in the Pandas core code, I came here first. Please let me know if this is actually an issue with the
awkward
orawkward_pandas
module.When calling
iterrows()
on a DataFrame which contains an awkward array as a column, a ValueError occurs (see stacktrace example). This error only occurs when all rows of the awkward array are of equal length. In this case the calls tovalues.astype(object)
and/ornp.asarray(values)
in theget_values
function in thepandas/core/internals/blocks.py
module result in a 2D array, instead of a 1D array with nested lists.When the awkward array is actually jagged, the call results in the correct format of the array (see commented line in code example) and
iterrows()
works as intended.Expected Behavior
I would expect
iterrows()
to iterate over the DataFrame rows without throwing an error, but instead returning a Series with the value of the awkward array at the index of the row set correctly.Installed Versions
INSTALLED VERSIONS
commit : d9cdd2e
python : 3.11.0.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.146.1-microsoft-standard-WSL2
Version : #1 SMP Thu Jan 11 04:09:03 UTC 2024
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.2.2
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 65.5.0
pip : 22.3
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 8.25.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2024.6.0
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: