变量:
y_hat = pd.DataFrame([x1,x2,x3,x4,x5])
y_actual = pd.DataFrame(Macro.iloc[8:13,1:2])
我有一个熊猫数据帧y_hat
:
y_hat
Out[24]:
0
0 409.612553
1 573.936775
2 256.213344
3 136.219153
4 419.977863
我有一个熊猫数据帧y_actual
:
y_actual
Out[25]:
y
8 422.40
9 580.42
10 256.76
11 128.96
12 445.42
我基本上是在试图计算一个MAPE(平均百分比误差)在y\u actual和y\u hat之间。R代码看起来像:
MAPE = colmeans(abs((y_hat - y_actual)/y_actual)*100)
但是,在Python中,我甚至无法通过第一步y_hat - y_actual
,因为它返回错误:
y_hat - y_actual
Out[29]:
0 y
0 NaN NaN
1 NaN NaN
2 NaN NaN
3 NaN NaN
4 NaN NaN
8 NaN NaN
9 NaN NaN
10 NaN NaN
11 NaN NaN
12 NaN NaN
我可以使用数据帧运行此计算吗?有没有一个Python函数等价于colmeans(列的平均值)
您可以在其他answer中使用类似的方法尝试以下操作:
相关问题 更多 >
编程相关推荐