Skip to content

BUG: .str.len() does not work if the dtype is a pyarrow-backed list #55344

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

Closed
2 of 3 tasks
ddutt opened this issue Oct 1, 2023 · 1 comment
Closed
2 of 3 tasks

BUG: .str.len() does not work if the dtype is a pyarrow-backed list #55344

ddutt opened this issue Oct 1, 2023 · 1 comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@ddutt
Copy link

ddutt commented Oct 1, 2023

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

import pandas as pd
import pyarrow as pa

df = pd.DataFrame({'a': pd.Series([[1, 2, 3], [4, 5, 6]],  dtype=pd.ArrowDtype(pa.list_(pa.int16())))})

df.a.str.len()

Issue Description

The above code aborts with the error: AttributeError: Can only use .str accessor with string values!

Expected Behavior

As per the description of str.len(), it should accept list-like dtypes to compute the length of each cell. If I use non-pyarrow backed lists, it works fine.

Installed Versions

In [7]: pd.show_versions() /work/.venv/lib/python3.11/site-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils. warnings.warn("Setuptools is replacing distutils.")

INSTALLED VERSIONS

commit : e86ed37
python : 3.11.3.final.0
python-bits : 64
OS : Linux
OS-release : 6.2.0-33-generic
Version : #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 7 10:33:52 UTC 2
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.1.1
numpy : 1.26.0
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 68.2.2
pip : 23.0
Cython : None
pytest : 7.4.2
hypothesis : 6.87.0
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.15.0
pandas_datareader : None
bs4 : None
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 13.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : 2.0.21
tables : None
tabulate : 0.8.10
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

@ddutt ddutt added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 1, 2023
@ddutt
Copy link
Author

ddutt commented Oct 1, 2023

Duplicate of #55323

@ddutt ddutt closed this as completed Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

1 participant