Open
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
df = pd.DataFrame({'a': [1, 2, 3, 4], 'b': ['a', 'b', 'c', 'd'], 'c': [1.2, 3.4, 5.6, 7.8], 'd': [..., ..., ..., ...]})
Issue Description
Based by SO question, I cannot replace by Ellipsis:
#working
df.mask(df == Ellipsis, 1)
df.replace(1, ...)
df.replace({Ellipsis: 1})
df .replace([...],(1))
#error
df.replace(..., 1)
df.replace(Ellipsis, 1)
TypeError: Expecting 'to_replace' to be either a scalar, array-like, dict or None, got invalid type 'ellipsis'
Expected Behavior
df = df.replace({Ellipsis: 1})
print (df)
a b c d
0 1 a 1.2 1
1 2 b 3.4 1
2 3 c 5.6 1
3 4 d 7.8 1
Installed Versions
print (pd.show_versions())
INSTALLED VERSIONS
------------------
commit : 2cb96529396d93b46abab7bbc73a208e708c642e
python : 3.8.8.final.0
python-bits : 64
OS : Windows
OS-release : 7
Version : 6.1.7601
machine : AMD64
processor : Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : en
LOCALE : sk_SK.ISO8859-2
pandas : 1.2.4
numpy : 1.23.1
pytz : 2021.1
dateutil : 2.8.1
pip : 21.0.1
setuptools : 52.0.0.post20210125
Cython : 0.29.23
pytest : 6.2.3
hypothesis : None
sphinx : 4.0.1
blosc : None
feather : None
xlsxwriter : 1.3.8
lxml.etree : 4.6.3
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.3
IPython : 7.22.0
pandas_datareader: 0.10.0
bs4 : 4.9.3
bottleneck : 1.3.2
fsspec : 0.9.0
fastparquet : None
gcsfs : None
matplotlib : 3.3.4
numexpr : 2.7.3
odfpy : None
openpyxl : 3.0.7
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.6.2
sqlalchemy : 1.4.7
tables : 3.6.1
tabulate : None
xarray : None
xlrd : 2.0.1
xlwt : 1.3.0
numba : 0.53.1
None