DataFrame要轉成輸出格式,可以用apply及list一次產生, 比用生成式[ row['...'] for i,row in df.iterrows()]快很多。
    df_no_match_io['desc'] = ''
    df_no_match_io['desc'] = df_no_match_io.apply( \
            lambda row: [ {'date':row['showDate'] \
                           , 'card_no':row['cardno'] \
                           , 'dept':row['dep'] \
                           , 'inspect':getDesc2(row)}] \
            ,axis=1)  
    returnResult = list(df_no_match_io['desc'])
 
 
 
沒有留言:
張貼留言