我使用pandas python来分析我的数据,我得到了枢轴熊猫的结果,如:
mae, mse,rmse,se
我需要从每个名称供应商获得平均值,我想要结果如下:
i = 0; //initialize counter
int k = 1; // second
float minx, maxx, miny, maxy, minz, maxz; // min and max values of the other 3 fields of the struct records
//initialize min and max
maxx = records[0].xaxis;
minx = records[0].xaxis;
maxy = records[0].yaxis;
miny = records[0].yaxis;
maxz = records[0].zaxis;
minz = records[0].zaxis;
for ( i = 1; i < n; i++){
//start looking for the maximum and the minimum
if(records[i].time <= k * 1000){//check only for values within the desired time period
if( records[i].xaxis > maxx ){
maxx = records[i].xaxis;
}
if( records[i].xaxis < minx ){
minx = records[i].xaxis;
}
if( records[i].yaxis > maxy ){
maxy = records[i].yaxis;
}
if( records[i].yaxis < miny ){
miny = records[i].yaxis;
}
if( records[i].zaxis > maxz ){
maxz = records[i].zaxis;
}
if( records[i].zaxis < minz ){
minz = records[i].zaxis;
}
}
else
{
neighbour[k-1].difx = maxx-minx;
neighbour[k-1].dify = maxy-miny;
neighbour[k-1].difz = maxz-minz;
k++;
maxx = records[i].xaxis;
minx = records[i].xaxis;
maxy = records[i].yaxis;
miny = records[i].yaxis;
maxz = records[i].zaxis;
minz = records[i].zaxis;
}
}
我该怎么做?名称供应商可以超过三个
THX
答案 0 :(得分:1)
df.mean().to_frame().T
产地:
namevendors A B C
0 2.285714 0.071429 0.071429