在我们读取一些excel/csv文件的数据后,在训练模型之前经常要对数据进行数组转化
解释含义如下:
Convert the frame to its Numpy-array representation.
当然很多时候在提取完数据后其自身就是数组形式(<class ‘numpy.ndarray’>),这只是习惯性的谨慎。很多时候取得的数据是DataFrame的形式,这个时候要记得转换成数组
eg:
x = datas.iloc[:,:].as_matrix()
当然这个方法已经快要被淘汰了,会出现如下的警告:
FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead.
我们只需要进行如下的转换即可:
x = datas.iloc[:,:].values
记住这个values没有括号