賽題地址:https://www.datafountain.cn/competitions/468/datasets
0.0846 code:
import pandas as pd
testA_df = pd.read_csv('../data/evaluation_public.csv')
sub = pd.read_csv('../data/submit_example.csv')
cpu_mean = testA_df.groupby(['ID'])['CPU_USAGE'].mean()
cpu_mean = cpu_mean.reset_index()
job_mean = testA_df.groupby(['ID'])['LAUNCHING_JOB_NUMS'].mean()
job_mean = job_mean.reset_index()
cpu_last = testA_df.groupby(['ID'])['CPU_USAGE'].last()
cpu_last = cpu_last.reset_index()
job_last = testA_df.groupby(['ID'])['LAUNCHING_JOB_NUMS'].last()
job_last = job_last.reset_index()
for i in range(1,6):
cpui = 'CPU_USAGE_' + str(i)
jobi = 'LAUNCHING_JOB_NUMS_' + str(i)
if i < 3:
sub[cpui] = cpu_last['CPU_USAGE'].astype(int)
sub[jobi] = job_last['LAUNCHING_JOB_NUMS'].astype(int)
else:
sub[cpui] = cpu_mean['CPU_USAGE'].astype(int)
sub[jobi] = job_mean['LAUNCHING_JOB_NUMS'].astype(int)
sub.to_csv('../subs/test_groupby_id_last2_mean3.csv',index=None)