这似乎是一个容易和简单的任务,但是我正在寻找基本而全面的答案,以对我的缺失值进行计数,以将它们编码为'?'字符。
我希望我的答案像这样:
drive_wheels 0
engine_location 0
engine_type 0
num_of_cylinders 0
fuel_system 0
bore 4
stroke 4
我尝试过这个:
for i in data.columns:
counter = 0
if data[i].dtype == '?':
counter += 1
else:
counter = 1
print(i, ' ', str(sum(counter)))
如果有人可以帮助我,我将不胜感激。谢谢!