python - ValueError:使用 np.randaom.multivariate_normal 设置具有序列的数组元素
问题描述
遇到以下代码块的问题,不确定问题是什么。有人建议调试吗?
mean = [0,0,0]
df_shape = df_arr.shape[0]
cov = [[.01/1525,0,0],[0,.01/2740,0],[0,0,.01/maxZ]]
draw = np.random.multivariate_normal(mean, cov, df_shape)
df_arr+draw
追溯细节:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/usr/local/lib/python3.6/site-packages/pandas/core/series.py in wrapper(self)
111 return converter(self.iloc[0])
--> 112 raise TypeError(f"cannot convert the series to {converter}")
113
TypeError: cannot convert the series to <class 'float'>
The above exception was the direct cause of the following exception:
ValueError Traceback (most recent call last)
<ipython-input-7-06eeed8242a3> in <module>
2 df_shape = df_arr.shape[0]
3 cov = [[.01/1525,0,0],[0,.01/2740,0],[0,0,.01/maxZ]]
----> 4 draw = np.random.multivariate_normal(mean, cov, df_shape)
5 df_arr+draw
mtrand.pyx in numpy.random.mtrand.RandomState.multivariate_normal()
ValueError: setting an array element with a sequence.
解决方案
推荐阅读
- python - QGIS 3损坏/禁用的python
- kubernetes - EKS 工作节点可以设置在不同的区域吗
- c# - 如何以编程方式将 UWP 应用程序从后台(最小化模式)带到前台?
- amazon-web-services - 使用 AWS Cognito 向自动确认的用户发送邀请电子邮件
- laravel-livewire - 将数据传递给 livewire 中的组件
- hybris - 目录同步太慢,虽然同步已完成
- excel - 打开有或没有配额的excel文件路径之间的差异
- c++ - 拆分循环依赖的 CRTP 类标头时与函数调用不匹配
- arrays - 在沙发库中搜索不区分大小写的数组
- javascript - 如何在 MongoDB 中查找包含搜索数组的一个或多个元素的文档?