缺失值处理
找出缺失值
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randn(10,6))
df.iloc[:4, 1] = None
df.iloc[:2, 4:6] = None
df.iloc[6, 3:5] = None
df.iloc[8, 0:2] = None
print(df)
0 1 2 3 4 5
0 1.905276 NaN -0.978137 1.682227 NaN NaN
1 0.164089 NaN -1.373336 1.388321 NaN NaN
2 0.599135 NaN 2.294221 0.737271 0.238057 0.526875
3 -0.481358 NaN -0.519011 0.214852 0.040489 0.599064
4 -0.358184 -0.794557 -0.454329 -1.024130 -0.090786 -0.018543
5 -0.679481 -0.126602 0.726568 1.432684 -1.403756 0.252173
6 -0.842605 1.192915 -0.831709 NaN NaN -0.073455
7 2.223354 -1.164356 -1.222986 0.009452 1.687198 0.344141
8 NaN NaN -1.024819 0.689602 1.210335 -0.714473
9 -0.397766 0.739464 -1.535297 -1.868259 0.724042 -1.714549
res = df.isnull()
res