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
The above code raises ValueError: Trying to coerce float values to integers on the development version (it is raised on 2.1.1 as well). However, if we force 'Int32', there is no error and the construction works as expected.
Expected Behavior
There should probably not be an error in the first place since .astype('int32') works as expected and extension dtypes also work as expected. Even if an error should be raised, the message is a bit off since the values are string representation of integers not floats, so perhaps the error message should be ValueError: Trying to coerce values to integers. Try astype instead. or something along those lines.
Installed Versions
commit : ea7bcd1
python : 3.12.0
OS : Windows 10
pandas : 3.0.0.dev0+880.gea7bcd14c8
numpy : 2.1.0.dev0+git20240402.e191a5f
The text was updated successfully, but these errors were encountered:
@rajat315315 I was actually working on a PR. Didn't think anybody would come in this fast lol. Anyway, let me know if you want to collaborate. I'm not a pandas dev so I don't have auth to merge or test or anything.
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
The above code raises
ValueError: Trying to coerce float values to integers
on the development version (it is raised on 2.1.1 as well). However, if we force'Int32'
, there is no error and the construction works as expected.Expected Behavior
There should probably not be an error in the first place since
.astype('int32')
works as expected and extension dtypes also work as expected. Even if an error should be raised, the message is a bit off since the values are string representation of integers not floats, so perhaps the error message should beValueError: Trying to coerce values to integers. Try astype instead.
or something along those lines.Installed Versions
commit : ea7bcd1
python : 3.12.0
OS : Windows 10
pandas : 3.0.0.dev0+880.gea7bcd14c8
numpy : 2.1.0.dev0+git20240402.e191a5f
The text was updated successfully, but these errors were encountered: