答案 0 :(得分:0)
将熊猫作为pd导入
df = pd.read_csv(r'Downloads \ test.txt',delimiter =',',encoding ='utf-8')
df_sort = df.sort_values(“ test”)
df_filter = df_sort [df_sort ['y']> = 5]
df_agg = df_filter.groupby(['test'])['x']。mean()
df_final = pd.merge(df_sort [['test','x','y']],df_agg,on ='test')
print(df_final)