BUG: Differences in setting value error between string dtype and others · Issue #49632 · pandas-dev/pandas (original) (raw)
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
ser = pd.Series(range(3), dtype="Int64") ser[0] = True
-> TypeError: Invalid value 'True' for dtype Int64
ser_str = pd.Series(range(3), dtype="string") ser_str[0] = True
-> ValueError: Cannot set non-string value 'True' into a StringArray.
Issue Description
Normally (in the case of nullable dtypes), setting a different type value will raise a TypeError
.
However, in the case of string dtype, it will raise a ValueError
instead.
Expected Behavior
The errors should be the same. (Is there a reason?)
Installed Versions
INSTALLED VERSIONS
commit : 91111fd
python : 3.10.6.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19044
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 9, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : Japanese_Japan.932
pandas : 1.5.1
numpy : 1.23.4
pytz : 2022.6
dateutil : 2.8.2
setuptools : 65.5.1
pip : 22.3.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.6.0
pandas_datareader: None
bs4 : None
bottleneck : None
brotli :
fastparquet : None
fsspec : 2022.10.0
gcsfs : None
matplotlib : 3.6.2
numba : 0.56.3
numexpr : None
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : 9.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.9.3
snappy : None
sqlalchemy : None
tables : None
tabulate : 0.9.0
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : None