1、数据清洗
常见数据异常
- 数据值缺失
- 数据值异常大或小
- 格式错误
- 非独立数据错误
import numpy as np
row_data = [
["Name", "StudentID", "Age", "AttendClass", "Score"],
["小明", 20131, 10, 1, 67],
["小花", 20132, 11, 1, 88],
["小菜", 20133, None, 1, "98"],
["小七", 20134, 8, 1, 110],
["花菜", 20134, 98, 0, None],
["刘欣", 20136, 12, 0, 12]
]
data = np.array(row_data) #list转换为array后,会跟一个dtype = xx
data
可以看到不同的 array 创建方式,可能会有不同的 dtype
,而data.dtype=object
,说明Python list 直接转换过来的 data 是无法参与诸多 Numpy 计算的。 而只有 dtype
为 int,float
这样的数值形式,才能参与运算。