【发布时间】:2019-01-29 23:20:54
【问题描述】:
我想将一个长列表转换为矩阵或向量,以便将其转换为度数。我不想使用“for”循环,因为列表太长,我希望我的程序尽可能快。我怎么能这样做?
编辑:
这是我迄今为止尝试过的,
latR=np.asarray(lat)
latR=np.degrees(latR)
但这就是我得到的:
ufunc 'degrees' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
谢谢!
【问题讨论】:
-
欢迎来到 SO。当您将错误复制/粘贴到 Google 中时,您发现了什么?
-
欢迎来到 StackOverflow,首先建议添加“numpy”标签以使您的问题更具体,然后您能告诉我们错误显示在哪一行吗?因为我认为在第二行(np.concatenate...)但不确定。
-
错误提示
lat包含非数字数据,或者numpy不知道如何处理。您能否包含一个简短的数据示例? (遵循stackoverflow.com/help/mcve 中的指南) -
你在
asarray函数之后看latR了吗?dtype是什么?shape?
标签: python list numpy matrix vector