相关疑难解决方法(0)

熊猫中的矩阵乘法

我有数据数据存储在两个DataFrames x和y中.来自numpy的内部产品起作用,但来自熊猫的点产品却没有.

In [63]: x.shape
Out[63]: (1062, 36)

In [64]: y.shape
Out[64]: (36, 36)

In [65]: np.inner(x, y).shape
Out[65]: (1062L, 36L)

In [66]: x.dot(y)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-66-76c015be254b> in <module>()
----> 1 x.dot(y)

C:\Programs\WinPython-64bit-2.7.3.3\python-2.7.3.amd64\lib\site-packages\pandas\core\frame.pyc in dot(self, other)
    888             if (len(common) > len(self.columns) or
    889                     len(common) > len(other.index)):
--> 890                 raise ValueError('matrices are not aligned')
    891 
    892             left = self.reindex(columns=common, copy=False)

ValueError: matrices are not aligned
Run Code Online (Sandbox Code Playgroud)

这是一个错误还是我使用熊猫错了?

python pandas

17
推荐指数
1
解决办法
3万
查看次数

标签 统计

pandas ×1

python ×1