Closed
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
import pandas as pd
#It's different
pd.DataFrame({
'ori':pd.Series([995279394541916024+i for i in range(128)]).astype('int64'),
'convert':pd.Series([995279394541916024+i for i in range(128)]).astype('float64').astype('int64'),
}
)
Issue Description
Unless the number is very small, converting float to int will result in different values.
And there will be no warning for this change.
import pandas as pd
pd.DataFrame({
'ori':pd.Series([995279394541916024+i for i in range(128)]).astype('int64'),
'convert':pd.Series([995279394541916024+i for i in range(128)]).astype('float64').astype('int64'),
}
)
Expected Behavior
#It's the same
pd.DataFrame({
'ori':pd.Series([995279394541916+i for i in range(128)]).astype('int64'),
'convert':pd.Series([995279394541916+i for i in range(128)]).astype('float64').astype('int64'),
}
)
Installed Versions
python ==3.9
pandas == 2.2.2