如何在python中检测空白值?

如何检测或检查所有功能中的空白值并将其可视化? (数据探索) 另一个问题:如果数据集不包含空白值, 结果是什么?

# Missing Or balnk values 
featurelist = []
count_of_blank_list = []

for col in dataset:
      cnt == ""
for i in dataset[col]:
    if i== "":
        cnt = cnt + 1
if col!='Class lable':
    #print (col, "-", cnt)
    featurelist.append(col)
    count_of_blank_list.append(cnt)

objects = tuple(featurelist)
y_pos = np.arange(len(featurelist))
performance = count_of_blank_list

fig_size = plt.rcParams["figure.figsize"]

# Set figure width to 12 and height to 9
fig_size[0] = 11
fig_size[1] = 3

plt.bar(y_pos, performance, align='center', color='b', alpha=0.9)
plt.xticks(y_pos, objects)

plt.ylabel('Count of blank values')
plt.title('Count of blank values per feature')
plt.grid(True)

plt.show()

NameError:名称“ cnt”未定义

评论