Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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.
'''
Comment

PREVIOUS NEXT
Code Example
Python :: python read csv into array 
Python :: jalali date to gregorian date 
Python :: pig latin translator python 
Python :: python: remove duplicate in a specific column 
Python :: dataframe all companies except 
Python :: ubuntu install python 3.8 
Python :: pandas drop all columns except certain ones 
Python :: how to make a star in python turtle 
Python :: sort python nested list according to a value 
Python :: python find dict in list of dict by id 
Python :: dataframe find nan rows 
Python :: python pandas dataframe column date to string 
Python :: blank lines with csv.writer 
Python :: how to put a text file into a list python 
Python :: filter dataframe columns vy a list of columns 
Python :: python current time 
Python :: python install pandas for linux 
Python :: how to time a python script 
Python :: count unique values numpy 
Python :: python how to read a xlsx file 
Python :: Create MySQL table from Python 
Python :: seaborn axis limits 
Python :: python get human readable file size 
Python :: python - give a name to index column 
Python :: tqdm for jupyter notebook 
Python :: how to get specific row in pandas 
Python :: how to read a file into array in python 
Python :: split a path into all subpaths 
Python :: how to create dynamic variable names in python 
Python :: how to save a dictionary to excel in python 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =