1. use sklearn

from sklearn.impute import SimpleImputer
import numpy as np

im = SimpleImputer(missing_values=np.nan, strategy='mean')
im = im.fit(df.values)
imputed_data = im.transform(df.values)

 

2. use dataframe method

df.fillna(df.mean())

'데이터분석 > pandas' 카테고리의 다른 글

encoding for class labels  (0) 2023.07.03
drop missing data in dataframe  (0) 2023.07.03
data cleaning  (0) 2019.11.06
nump 사용  (0) 2019.10.31
data crawling  (0) 2019.10.28

+ Recent posts