Answers for "pandas columns to int64 with nan"

0

pandas columns to int64 with nan

# 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 "pandas columns to int64 with nan"

Python Answers by Framework

Browse Popular Code Answers by Language