modle.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:forward 作者: yajun0601 项目源码 文件源码
def process():
    df=pd.read_excel(DATA_FILE,sheetname=[1], header = 0,index_col=0,convert_float=False)[1]
#    df0 = df[1].fillna(0)
#    df = df.head(100)
#    resultList=np.zeros(df.index.size)
    resultList=[]
    idList=[]
    for i in range(df.index.size):
        for nan in range(1,40):
            if math.isnan(df.values[i][nan]):
#                print(df[1].values[i])
                df.values[i][40]=np.nan
                break
        if nan < 39: # for nan results
            idList.append(df.index[i])
            resultList.append([df.values[i][0],0])
            print("%s:%s"%(df.index[i],df.values[i][0]))
            continue
        ID=df.index[i]
        df.values[i][0]
        data=df.values[i][1:40].reshape(13,3)
# handle nulls        
#        print(data)
        industryScore = calcIndustry(ID,data)
        trendScore = calcTrend(ID,data)
        fluncScore = calcFluctuation(ID,data)
        a = np.append(industryScore,trendScore)
        b= np.append(a,fluncScore)
        idList.append(ID)
        resultList.append([df.values[i][0],calcTotal(b)])

#        print("%s:%f"%(ID,resultList[i]))
    resultdf=pd.DataFrame(resultList,idList,columns=['NAME','Score'])
    with pd.ExcelWriter('result.xls') as writer:
        resultdf.to_excel(writer,sheet_name=str(0))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号