如何解决值错误:错误长度 103 与索引 180 不匹配
请检查这些图像我对python了解不多 我没有足够的知识来解决这个问题,有人告诉我我必须在我的数组中传递空值,但我担心这可能会导致准确性下降。请帮助我理解为什么会发生这种情况以及如何解决这个问题
Scarborough_Avg_HousingPrice=pd.DataFrame({"Neighborhood":df_2["Neighborhood"],"Average_Housing_Price":[335000.0,286600.0,175000.0,225900.0,219400.0,573900.0,225000.0,370500.0,433500.0,279200.0,370500.,255400.0,435000.0,289500.0,265000.0,285900.0,239400.0,589900.0,295000.0,380500.0,378500.0,438500.0,229200.0,365000.0,388500.,285400.0,493500.0,477500.0,378000.0,316600.0,195000.0,367000.0,363500.0,271000.0,383500.0,335000.0,185000.0,329000.0,533500.0,375000.0,165000.0,425000.0,403500.0,187000.0,325000.0,333500.0,289000.0,413500.0,254800.0
]})
这是代码 [2]:https://i.stack.imgur.com/5EUqL.png C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-packages\pandas\core\frame.py in init(self、data、index、columns、dtype、copy) 466 467 elif isinstance(数据,字典): --> 468 mgr = init_dict(数据、索引、列、dtype=dtype) 469 elif isinstance(数据,ma.MaskedArray): 470 将 numpy.ma.mrecords 导入为 mrecords C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-packages\pandas\core\internals\construction.py in init_dict(data,index,columns,type) 第 281 章 第282话 --> 283 return arrays_to_mgr(arrays,data_names,dtype=dtype) 284 285 C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-packages\pandas\core\internals\construction.py in arrays_to_mgr(arrays,arr_names,dtype,verify_integrity) 76 # 找出索引,如果需要的话 77 如果索引为无: ---> 78 索引 = 提取索引(数组) 79 其他: 80 索引 = 确保索引(索引)
C:\ProgramData\Anaconda3\envs\pythonProject\lib\site-packages\pandas\core\internals\construction.py in extract_index(data) 第409话 第410章 --> 411 引发 ValueError(msg) 412 其他: 413 索引 = ibase.default_index(lengths[0])
ValueError: 数组长度 103 与索引长度 180 不匹配
这是错误
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。