Description
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
pd.Series(["A", "AB", "ABC"], dtype=pd.ArrowDtype(pa.string())).str.zfill(3)
Issue Description
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/will/GitHub/various/narwhals/.venv/lib/python3.12/site-packages/pandas/core/strings/accessor.py", line 137, in wrapper
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/will/GitHub/various/narwhals/.venv/lib/python3.12/site-packages/pandas/core/strings/accessor.py", line 1818, in zfill
result = self._data.array._str_map(f)
^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ArrowExtensionArray' object has no attribute '_str_map'. Did you mean: '_str_pad'?
Expected Behavior
Same as other string dtypes
Installed Versions
INSTALLED VERSIONS
commit : 0691c5c
python : 3.12.9
python-bits : 64
OS : Darwin
OS-release : 23.6.0
Version : Darwin Kernel Version 23.6.0: Fri Jul 5 17:56:39 PDT 2024; root:xnu-10063.141.1~2/RELEASE_ARM64_T8122
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.2.3
numpy : 2.2.6
pytz : 2025.2
dateutil : 2.9.0.post0
pip : None
Cython : None
sphinx : None
IPython : 9.2.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : 6.131.23
gcsfs : None
jinja2 : 3.1.6
lxml.etree : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 20.0.0
pyreadstat : None
pytest : 8.3.5
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2025.2
qtpy : None
pyqt5 : None
Activity
Expr.str.zfill
narwhals-dev/narwhals#2598arthurlw commentedon May 28, 2025
Confirmed on main.
ArrowExtensionArray
doesn’t implement_str_map
, so.str.zfill
fails. PRs to add this support are welcome.Thanks for raising this!
iabhi4 commentedon Jun 1, 2025
take
BUG: Fix Series.str.zfill for ArrowDtype string arrays pandas-dev#61485
utf8_zfill
in pyarrow.compute to supportstr.zfill
behavior apache/arrow#46683iabhi4 commentedon Jun 3, 2025
Just raised an upstream feature request in Arrow to support
utf8_zfill
, which would allow us to use a native compute kernel instead of falling back to Python forstr.zfill()
on Arrow-backed string arrays.Tracking here
BUG: Fix Series.str.zfill for ArrowDtype string arrays pandas-dev#61485
BUG: Fix Series.str.zfill for ArrowDtype string arrays pandas-dev#61485
BUG: Fix Series.str.zfill for ArrowDtype string arrays pandas-dev#61485
BUG: Fix Series.str.zfill for ArrowDtype string arrays pandas-dev#61485
BUG: Fix Series.str.zfill for ArrowDtype string arrays pandas-dev#61485