Pandas version checks
-
[x] I have checked that this issue has not already been reported.
-
[x] I have confirmed this bug exists on the latest version of pandas.
-
[x] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
import re
DATA = ["applep", "bananap", "Cherryp", "DATEp", "eGGpLANTp", "123p", "23.45p"]
s=pd.Series(DATA)
s.str.fullmatch(re.compile(r"applep"))
s.str.match(re.compile(r"applep"))
sa=pd.Series(DATA, dtype="string[pyarrow]")
sa.str.fullmatch(re.compile(r"applep"))
sa.str.match(re.compile(r"applep"))
Issue Description
with pyarrow strings, the last line fails with:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Condadirs\envs\pandasstubs311\Lib\site-packages\pandas\core\strings\accessor.py", line 140, in wrapper
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Condadirs\envs\pandasstubs311\Lib\site-packages\pandas\core\strings\accessor.py", line 1429, in fullmatch
result = self._data.array._str_fullmatch(pat, case=case, flags=flags, na=na)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Condadirs\envs\pandasstubs311\Lib\site-packages\pandas\core\arrays\_arrow_string_mixins.py", line 320, in _str_fullmatch
if not pat.endswith("$") or pat.endswith("\\$"):
^^^^^^^^^^^^
AttributeError: 're.Pattern' object has no attribute 'endswith'
>>> sa.str.match(re.compile(r"applep"))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Condadirs\envs\pandasstubs311\Lib\site-packages\pandas\core\strings\accessor.py", line 140, in wrapper
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Condadirs\envs\pandasstubs311\Lib\site-packages\pandas\core\strings\accessor.py", line 1388, in match
result = self._data.array._str_match(pat, case=case, flags=flags, na=na)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Condadirs\envs\pandasstubs311\Lib\site-packages\pandas\core\arrays\_arrow_string_mixins.py", line 309, in _str_match
if not pat.startswith("^"):
^^^^^^^^^^^^^^
AttributeError: 're.Pattern' object has no attribute 'startswith'
Expected Behavior
No exception
Installed Versions
INSTALLED VERSIONS
------------------
commit : c888af6d0bb674932007623c0867e1fbd4bdc2c6
python : 3.11.9
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.26100
machine : AMD64
processor : Intel64 Family 6 Model 183 Stepping 1, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
pandas : 2.3.1
numpy : 2.3.1
pytz : 2024.1
dateutil : 2.9.0.post0
pip : 24.2
Cython : None
sphinx : None
IPython : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.13.4
blosc : None
bottleneck : 1.4.2
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : 1.1
hypothesis : None
gcsfs : None
jinja2 : 3.1.6
lxml.etree : 6.0.0
matplotlib : 3.10.3
numba : None
numexpr : 2.10.1
odfpy : None
openpyxl : 3.1.5
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 20.0.0
pyreadstat : 1.3.0
pytest : 8.4.1
python-calamine : None
pyxlsb : 1.0.10
s3fs : None
scipy : 1.16.0
sqlalchemy : 2.0.41
tables : 3.10.1
tabulate : 0.9.0
xarray : 2025.6.1
xlrd : 2.0.2
xlsxwriter : 3.2.5
zstandard : None
tzdata : 2025.2
qtpy : None
pyqt5 : None