6
我想要做一个熊猫数据帧的矩阵multiplcation等一系列矩阵乘法和系列
df = pandas.DataFrame({'a':[4,1,3], 'b':[5,2,4]},index=[1,2,3])
ser = pandas.Series([0.6,0.4])
df是,
a b
1 4 5
2 1 2
3 3 4
SER是,
0 0.6
1 0.4
我期望的结果是矩阵产品,就像这样
答是,
我可以用numpy的点运算符和重建我的数据帧
c = a.values.dot(b.transpose())
c = pandas.DataFrame(c, index = a.index, columns = ['ans'])
print c
ans
1 4.4
2 1.4
3 3.4
是否有大熊猫本地方法来做到这一点做到这一点?