pandas去空 对齐运算
去空
df6=pd.DataFrame([np.random.randint(10,50,4),[1.1,2.2,3.3,],[np.NAN,1,2,3]])
print(df6)
判断单个元素是否为空
ret=df6.isnull()
print(ret)
print()
和上面的相反
ret2=df6.notnull()
print(ret2)
print('######################')
去掉空的列
ret3=df6.dropna(axis=1)
print(ret3)
print()
去掉空的行
ret4=df6.dropna(axis=0)
print(ret4)
print()
print('#####################')
把所有空值填充为0
ret3=df6.fillna(0)
print(ret3)
按列索引填充空值,这里key为列索引
ret4=df6.fillna({0:0,3:100})
print(ret4)
去重
df1=pd.DataFrame({'data1':list('aabbccdd'),'data2':[1,2,3,4,1,2,3,5]})
print(df1)
print()
测试是否存在重复值
ret5=d