其他分享
首页 > 其他分享> > aaa

aaa

作者:互联网

# 消耗
def get_pot_info(self):
df = pd.read_json(self.pump_log_file, lines=True)
if not df.empty:
df = df[df['package'] != 'robot']
self.df.append(df.groupby(['app', 'channel', 'package'], as_index=False)["pump"].count().rename(
columns={"pump": "coin_pump"}))
else:
self.df.append(DataFrame(columns=['app', 'channel', 'package', 'coin_pump']))


def analysis(self):
log.info("start handle %s" % self.pot_info_log_file)
dfr = pd.read_json(self.pot_info_log_file, lines=True)
df = dfr[dfr['package'] != 'robot']
df = df.groupby(['app', 'channel', 'version', 'game_id'], as_index=False)['pump'].sum().rename(columns={'pump': 'xiaohao'})
df = df.fillna(0)
self.save_property_statics_pump(df)

def save_property_statics_pump(self, df):
log.info("开始金币消耗表,数据量:{0}".format(df.shape))
sql = list()
sql.append("replace into property_stastics_pump(app,version,channel,property_id,xiaohao,create_at,reason_id) values ")
if df.shape[0] <= 0:
return
for row_index, row in df.iterrows():
sql.append("('%s','%s','%s',%s,%s,'%s',%s)," %
(row['app'], row['version'], row['channel'], 1, row['xiaohao'],
self.current_date, row['game_id']))
sql = "".join(sql)[:-1]
print(sql)
self.mysql_con.excute(sql)
log.info("结束道具产销表存储")

标签:aaa,log,df,self,pump,sql,row
来源: https://www.cnblogs.com/niuniuc/p/10451935.html