Answers for "Cannot convert non-finite values (NA or inf) to integer"

0

Cannot convert non-finite values (NA or inf) to integer

# single column
df['column_name'].apply(pd.to_numeric).astype('Int64')

# range of cols
df.loc[:, 'col_n':'col_m'] = df.loc[:, 'col_n':'col_m'].apply(pd.to_numeric).astype('Int64')

'''
From Pandas v0.24, introduces Nullable Integer Data Types 
which allows integers to coexist with NaNs.
'''
Posted by: Guest on March-08-2022

Code answers related to "Cannot convert non-finite values (NA or inf) to integer"

Python Answers by Framework

Browse Popular Code Answers by Language