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
Thanks for the report! Confirmed on main. It looks like pandas.core.array_algos.replace.compare_or_regex_search does not properly handle the case of all NA values. Further investigations and PRs to fix are welcome!
Upon further investigation, I found that this is indeed a bug in pandas.core.array_algos.replace.compare_or_regex_search as @rhshadrach mentioned earlier. It uses np.vectorize to call a vectorized operation on non-NA elements in the array which, in this case, would be an empty array. This apparently works only if the otypes argument is set when calling np.vectorize. Created PR #60691 to fix this.
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
Using replace with a regex pattern on a single-row DataFrame containing
None
values raises the following error:Expected Behavior
The replace function should handle
None
values gracefully without requiring a manual fill or type conversion.Installed Versions
INSTALLED VERSIONS
commit : 0691c5c
python : 3.11.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.27766
machine : AMD64
processor : Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_Denmark.1252
pandas : 2.2.3
numpy : 2.0.2
pytz : 2024.2
dateutil : 2.9.0.post0
pip : 24.3.1
Cython : None
sphinx : None
IPython : 8.30.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
blosc : None
bottleneck : 1.4.2
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : 1.1
hypothesis : None
gcsfs : None
jinja2 : 3.1.4
lxml.etree : 5.3.0
matplotlib : 3.9.2
numba : 0.60.0
numexpr : 2.10.2
odfpy : None
openpyxl : 3.1.5
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 18.1.0
pyreadstat : None
pytest : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.14.1
sqlalchemy : 2.0.36
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2024.2
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: