利用pandas读取excel 筛选0值超过99%的列,并删除
import pandas as pd df1=pd.read_csv(r"123.csv") df=pd.DataFrame(df1) nrows=df.shape[0] ncols=df.columns.size del_col=[] for j in range(ncols) : sum = 0 for ai in df.iloc[:,j]: if ai == 0.0 : sum+=1 if float(sum)/nrows>=0.99: del_col.append(j) print del_col
|