2023年7月26日发(作者:)
python报错:listobjecthasnoattributeshape的解决可使⽤ shape。list不能使⽤shape。可以使⽤(list A)进⾏转换。(array转list:array B ()即可)补充知识:Pandas使⽤DataFrame出现错误:AttributeError: 'list' object has no attribute 'astype'在使⽤Pandas的DataFrame时出现了错误:AttributeError: ‘list' object has no attribute 'astype'代码⼊下:import pandas as pdpop = {'Nevada': {2001: 2.4, 2002: 2.9},'Ohio': {2000: 1.5, 2001: 1.7, 2002: 3.6}}ame(pop, index=[2001, 2002, 2003])错误提⽰如下:原因:可能是Pandas版本问题,语法格式不正确。解决办法:将代码写成如下格式,再次运⾏,没有报错。ame(pop,columns=['Nevada', 'Ohio'],index=[2001,2002,2003])#或者也可以写成下⾯这样:ame(pop,index=([2001,2002,2003]))以上这篇python报错: 'list' object has no attribute 'shape'的解决就是⼩编分享给⼤家的全部内容了,希望能给⼤家⼀个参考,也希望⼤家多多⽀持。
发布者:admin,转转请注明出处:http://www.yc00.com/web/1690305996a329649.html
评论列表(0条)