# handling missing values
class handling_missing_data():
# Imputation
# Handling columns which have null values
for col in df[:]:
if ():
if (pd.df[:].astype(pd.Series([np.integer]))):
df = df.select_dtypes(include=[np.integer]).fillna(df.select_dtypes(include=[np.integer]).mean().iloc[0], inplace=True)
elif (pd.df[:].astype(pd.Series([object, str]))):
df = df.select_dtypes(include=['object', 'str']).fillna(df.select_dtypes(include=['object', 'str']).mode().iloc[0], inplace=True)
print(df.head())
为什么这段代码不起作用,因为我正在尝试识别特定列中dataset中缺少的值,并通过使用循环使用基于列数据类型的mean、mode填充缺少的列值。我正在寻找一些通用的方法
您的代码有太多错误,无法在回答中合理地进行检查,所以让我来告诉您我将如何做
相关问题 更多 >
编程相关推荐