-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Series.__setitem__ fails with non range index while upcasting dtype #45070
Comments
0 is not part of your index, so the KeyError is correct the traceback is a bit weird, but the behavior is ok |
So I think the KeyError is not expected here |
Did not remember that. We use numpy for this here. Which is where the error comes from:
Reading the code and the user guide: This is intended to work like numpy does, so not sure if the error is unexpected here.
In general I would recommend using iloc for this case. |
this is hitting the fallback path |
Best guess: in _set_with_engine we call validate_numeric_casting, which fails to raise here. instead we can do replacing validate_numeric_casting with can_hold_element checks changes some other behavior (and im concerned about perf) but deduplicating these would be worthwhile. |
|
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 master branch of pandas.
Reproducible Example
Issue Description
Currently it raises an error, I think it is considered to be a bug while 39584 is not decided.
Expected Behavior
Either correctly set the value and upcast dtype to
object
, either keep raising an error depending on 39584 output.Installed Versions
INSTALLED VERSIONS
commit : db08276
python : 3.8.10.final.0
python-bits : 64
OS : Linux
OS-release : 5.11.0-43-generic
Version : #47~20.04.2-Ubuntu SMP Mon Dec 13 11:06:56 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : fr_FR.UTF-8
LOCALE : fr_FR.UTF-8
pandas : 1.1.3
numpy : 1.19.5
pytz : 2019.3
dateutil : 2.8.2
pip : 20.0.2
setuptools : 45.2.0
Cython : None
pytest : 6.2.4
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 3.0.1
IPython : 7.25.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : 2021.10.1
fastparquet : 0.7.1
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : 6.0.0
pytables : None
pyxlsb : None
s3fs : 2021.10.1
scipy : None
sqlalchemy : None
tables : None
tabulate : 0.8.9
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: