Python学习:问题 VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a

遇到的问题:在pycharm中运行数组运算,出现警告

 VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.

经过查询,参考

VisibleDeprecationWarning , Creating an ndarray from ragged nested sequences... 警告怎么办 - xiake_shuoshuo - 博客园 (cnblogs.com)icon-default.png?t=LA92https://www.cnblogs.com/yinshuo666/p/15014968.htmlVisible Deprecation Warning: Creating an ndarray from ragged nested sequences (which is list or tupl_球场书生的博客-CSDN博客icon-default.png?t=LA92https://blog.csdn.net/qq_41917697/article/details/115698304对代码进行修改,添加dtype=object,警告消失。

问题解除。

import numpy as np
#举例
a = np.array([[0, 1, 2, 3, 4], [5, 6, 7, 8]], dtype=object)

你可能感兴趣的:(python,开发语言)