Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 矩阵未对齐确认矩阵适当尺寸的错误消息_Python_Pandas - Fatal编程技术网

Python 矩阵未对齐确认矩阵适当尺寸的错误消息

Python 矩阵未对齐确认矩阵适当尺寸的错误消息,python,pandas,Python,Pandas,基于我对矩阵乘法的了解和其他类似问题的评论,似乎这个产品应该可以工作 X.shape (11030232) 初始形状 (32,1) X.dot(首字母) ValueError回溯(最近一次调用) 在里面 ---->1 X.dot(初始θ) ~/opt/anaconda3/lib/python3.7/site-packages/pandas/core/frame.py in dot(self,other) 1061 common=self.columns.union(其他.index) 1062

基于我对矩阵乘法的了解和其他类似问题的评论,似乎这个产品应该可以工作

X.shape

(11030232)

初始形状

(32,1)

X.dot(首字母)


ValueError回溯(最近一次调用)
在里面
---->1 X.dot(初始θ)
~/opt/anaconda3/lib/python3.7/site-packages/pandas/core/frame.py in dot(self,other)
1061 common=self.columns.union(其他.index)
1062如果len(公共)>len(自列)或len(公共)>len(其他索引):
->1063提升值错误(“矩阵未对齐”)
1064
1065 left=self.reindex(列=common,副本=False)
ValueError:矩阵未对齐

我用numpy和pandas进行了测试,它们都为我工作。您正在执行的确切代码是什么?我附上了Jupyter笔记本中代码片段的图像。我不会添加代码的其余部分,因为这不太可能有帮助。@Iam,添加代码的其余部分,或者一些演示问题的等效代码,是唯一有帮助的。
ValueError                                Traceback (most recent call last)
<ipython-input-29-6374e4f84506> in <module>
----> 1 X.dot(initial_theta)

~/opt/anaconda3/lib/python3.7/site-packages/pandas/core/frame.py in dot(self, other)
   1061             common = self.columns.union(other.index)
   1062             if len(common) > len(self.columns) or len(common) > len(other.index):
-> 1063                 raise ValueError("matrices are not aligned")
   1064 
   1065             left = self.reindex(columns=common, copy=False)

ValueError: matrices are not aligned