ENH: Add list accessor for PyArrow list types to support getitem · Issue #55323 · pandas-dev/pandas (original) (raw)

Pandas version checks

Reproducible Example

import pyarrow as pa

works

pd.Series(["tsht(thsat","gda(gr"]).str.split("(").str[0]

works

pd.Series(["tsht(thsat","gda(gr"], dtype="string[pyarrow]").str.split("(").str[0]

fails

pd.Series(["tsht(thsat","gda(gr"], dtype=pd.ArrowDtype(pa.string())).str.split("(").str[0]

Issue Description

raise AttributeError("Can only use .str accessor with string values!")

AttributeError: Can only use .str accessor with string values!

Expected Behavior

pd.Series(["tsht(thsat","gda(gr"], dtype=pd.ArrowDtype(pa.string())).str.split("(").str[0]

should do the same as the rest, also i would not use pd.ArrowDtype(pa.string(), but it just happens to be the default datatype when reading a file using pd.read_excel.

Installed Versions

DEBUG - matplotlib: matplotlib data path: C:\Users\PabloRuiz\AppData\Local\pypoetry\Cache\virtualenvs\transformer-wi-nHELc-py3.11\Lib\site-packages\matplotlib\mpl-data

DEBUG - matplotlib: CONFIGDIR=C:\Users\PabloRuiz.matplotlib
DEBUG - matplotlib: interactive is False
DEBUG - matplotlib: platform is win32
INSTALLED VERSIONS

commit : e86ed37
python : 3.11.1.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19045
machine : AMD64
processor : Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
pandas : 2.1.1
numpy : 1.26.0
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 68.2.2
pip : 22.3.1
Cython : None
pytest : 7.4.2
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 3.1.4
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 : 3.8.0
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.3
pandas_gbq : None
pyarrow : 13.0.0
pyreadstat : None
pyxlsb : 1.0.10
s3fs : None
scipy : None
sqlalchemy : 1.4.31
tables : None
tabulate : None
xarray : None
xlrd : 2.0.1
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None