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. newArr = np.array(list_A)

原因
list里添加数组元素时没有正确索引,导致append加入的是array,后续将list通过np.array进行转换时出现警告

解决方法
x = B[0][i]后添加[0]

也可能存在的原因:列表不规则,长短不一,在np.array(list_A)之前检查list_A

Code

import numpy as npprint(numpy.__version__) # 1.22.2
A = np.arange(1, 25).reshape(4, 6)list_A = A.flatten().tolist()B = np.array([[[0, 2, 3, 4], [5, 6, 7, 8]]], dtype=np.int32)
print(A)
print(list_A)
"""
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. newArr = np.array(list_A)
"""
for i in range(B.shape[1]):x = B[0][i]# type(x) : <class 'numpy.ndarray'>  DeprecationWarning# x = B[0][i][0]# solve type(x) : <class 'numpy.int32'># print(type(x))list_A.append(x)print(list_A)
newArr = np.array(list_A)
print(newArr)

VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences相关推荐

  1. VisibleDeprecationWarning , Creating an ndarray from ragged nested sequences... 警告怎么办?

    我不是完美主义,但是至少,我在做实验的时候不能容忍有 warning 的出现. 今天使用 tensorflow.keras.datasets中的 imdb 数据集,使用 imdb.load_data( ...

  2. VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tupl

    构造一个多维数组时,出现问题: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which i ...

  3. numpy之 警告VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences

    目录 警告 解决 警告 这是我写的读取npz文件的代码, datas = np.load("bsm.npz", allow_pickle=True) print(datas.fil ...

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

    遇到的问题:在pycharm中运行数组运算,出现警告 VisibleDeprecationWarning: Creating an ndarray from ragged nested sequenc ...

  5. 【Bug解决】VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences

    问题描述 VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or ...

  6. python报错 VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences

    python报错 VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences 报错原因:numpy中元素sh ...

  7. python numpy报错:VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences

    注意:标题中说是"报错",但是这事实上只是"警告".表依然可以正常导出. 今天遇到了这个问题,查到了这篇博文:https://blog.csdn.net/Aug ...

  8. 【Bug修复】VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences

    问题描述: 在通过array()函数创建numpy数组时,因为array()函数是可以直接传入已有数据类型,所以,就直接使用dtype去查看类型,此时出现了一个警告. 代码: import numpy ...

  9. Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or nda

    python报错 VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a lis ...

最新文章

  1. Android 中文 API (25) —— ZoomControls
  2. greta的问题及解决: LIBCMTD.lib(_wctype.obj) : error LNK2005: _iswspace already defined in xxx.obj...
  3. sqlplus命令行登录oracle数据库的N种方法盘点
  4. 825. 适龄的朋友
  5. 华为Mate 40手机将于国庆节发售:搭载全新5nm芯片
  6. c/c++教程 - 1.5 运算符
  7. lesson 7 strategies for efficient CUDA programming
  8. java架构说明书_JDBC 使用说明(流程、架构、编程)
  9. 告白气球--吉他教学
  10. python开发板卡驱动开发_一款能让你发挥无限创意的MicroPython开发板—TPYBoard开发板测...
  11. mybatis一简单one2one关系xml配置
  12. 94. autoload(2)
  13. 单片机c语言出租车计时程序,基于单片机的出租车计费(c语言
  14. 桌面客户端框架技术选型
  15. speedoffice(Word)怎么修改字体颜色呢
  16. Kali下卸载程序和安装程序的方法
  17. 智能音箱硬件和软件介绍[上] 硬件结构解析[Soomal]
  18. 用Keras构建神经网络的3种方法
  19. python中日期的数据类型_强制日期时间转换,强制日期时间数据类型,在pandas中使用read_表...
  20. 不会Ps?没关系,这些在线平面设计网站,很实用

热门文章

  1. WebView-WebViewClient详解
  2. 视频目标检测与图像目标检测的区别
  3. linux运维要经常加班吗,请好好善待你身边的Linux运维工程师,因为他们…
  4. 软考程序员大纲2004
  5. 从感知机到Transformer,一文概述深度学习简史
  6. 嵌入式软件工程师—成长笔记#02
  7. 排名前6位的最流行的大数据框架,你在用哪一款?
  8. 虚拟机扩展(VMX)简介
  9. (转载)常见的差分(动)阻抗计算模型(CITS25 软件)
  10. 手机数字雨_cmd命令如何实现数字雨的效果