我正在预处理此数据集http://datahack.analyticsvidhya.com/contest/practice-problem-big-mart-sales-iii,它同时具有分类和数字变量。 我使用sklearn的Imputer来估算缺失的值。我已经确认只有两列(Item_Weight和Outlet_Size)缺少值。我没有在我的数据中将分类变量转换为数字变量。 目前我使用
imp = Imputer(missing_values='NaN', strategy='most_frequent', axis=0)
处理缺失值,当我运行imp.fit(mydata)
时,会出现错误消息:ValueError: could not convert string to float: Supermarket Type1
但“超市类型1”是“outlet_type”列中的值,而不是具有缺失值的列。
那么为什么Imputer处理列而不会丢失值?我认为它只处理缺少值的列。