BUG: setting with iloc and no labels does not effect certain data types #34217
Labels
Bug
Dtype Conversions
Unexpected or buggy dtype conversions
Indexing
Related to indexing on series/frames, not to indexes themselves
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
Column "a" remains an int64 whereas it should be int32. This is similar to #33198, however the resolution there (taking the split path in _setitem_with_indexer) is not sufficient in this case where there are no labels. The issue appears to be the function
pandas/pandas/core/dtypes/cast.py
Lines 86 to 95 in 9f7b9fc
values enters here as int32 and gets converted to int64 in the call to maybe_convert_objects. Indeed, adding the line
after the call to maybe_convert_objects gives the right output.
Should maybe_convert_objects take into account int32 vs int64, float32 vs float64, and others?
One last note: even if maybe_convert_objects returned int32 here, it would not resolve #33198.
The text was updated successfully, but these errors were encountered: