当前位置: 首页 > news >正文

AssertionError: 618 columns passed, passed data had 508 columns【已解决】

问题描述

程序中断,报错如下AssertionError: 618 columns passed, passed data had 508 columns

Exception has occurred: ValueError
618 columns passed, passed data had 508 columns
AssertionError: 618 columns passed, passed data had 508 columnsThe above exception was the direct cause of the following exception:File "E:\matlab\CHB-MIT-DATA\epilepsy_eeg_classification\preprocessing.py", line 117, in eeg_preprocessingres = pd.DataFrame(res, columns=column_names)File "E:\matlab\CHB-MIT-DATA\epilepsy_eeg_classification\preprocessing.py", line 334, in <module>res = eeg_preprocessing(file, seizures)
ValueError: 618 columns passed, passed data had 508 columns

 terminal报错如下:

Backend Qt5Agg is interactive backend. Turning interactive mode on.

 

弯路

numpy1.19.4改为了numpy1.21.6

pip list: numpy1.21.6

conda list: numpy1.20.1

发现,报错仍旧一样,没有任何改变。

我的怀疑是数据里面有nan值,而程序中并没有处理的方法,是丢弃是补充为0还是补充为平均值。因为如果丢弃的话。

我发现numpy版本不对,卸载的时候,报错说:

PackageNotInstalledError: Package is not installed in prefix

于是我使用

conda udate numpy

报错如下:

(base) PS E:\matlab> conda update numpy
Collecting package metadata (repodata.json): done
Solving environment: -
The environment is inconsistent, please check the package plan carefully
The following packages are causing the inconsistency:- defaults/win-64::anaconda==custom=py37_1- https://repo.anaconda.com/pkgs/main/win-64::bkcharts==0.2=py37_0- https://repo.anaconda.com/pkgs/main/win-64::blaze==0.11.3=py37_0- https://repo.anaconda.com/pkgs/main/win-64::bokeh==0.13.0=py37_0- https://repo.anaconda.com/pkgs/main/win-64::dask==0.19.1=py37_0- https://repo.anaconda.com/pkgs/main/win-64::numpydoc==0.8.0=py37_0- https://repo.anaconda.com/pkgs/main/win-64::odo==0.5.1=py37_0- https://repo.anaconda.com/pkgs/main/win-64::seaborn==0.9.0=py37_0- https://repo.anaconda.com/pkgs/main/win-64::sphinx==1.7.9=py37_0- https://repo.anaconda.com/pkgs/main/win-64::spyder==3.3.1=py37_1- https://repo.anaconda.com/pkgs/main/win-64::statsmodels==0.9.0=py37h452e1ab_0- defaults/win-64::_anaconda_depends==5.3.1=py37_0
failedCondaMemoryError: The conda process ran out of memory. Increase system memory and/or try again.

有人说可以直接退到base环境更新conda。

(base) PS E:\matlab> conda update --name base conda
Collecting package metadata (repodata.json): done
Solving environment: |
The environment is inconsistent, please check the package plan carefully
The following packages are causing the inconsistency:- defaults/win-64::anaconda==custom=py37_1- https://repo.anaconda.com/pkgs/main/win-64::bkcharts==0.2=py37_0- https://repo.anaconda.com/pkgs/main/win-64::blaze==0.11.3=py37_0- https://repo.anaconda.com/pkgs/main/win-64::bokeh==0.13.0=py37_0- https://repo.anaconda.com/pkgs/main/win-64::dask==0.19.1=py37_0- https://repo.anaconda.com/pkgs/main/win-64::numpydoc==0.8.0=py37_0- https://repo.anaconda.com/pkgs/main/win-64::odo==0.5.1=py37_0- https://repo.anaconda.com/pkgs/main/win-64::seaborn==0.9.0=py37_0- https://repo.anaconda.com/pkgs/main/win-64::sphinx==1.7.9=py37_0- https://repo.anaconda.com/pkgs/main/win-64::spyder==3.3.1=py37_1- https://repo.anaconda.com/pkgs/main/win-64::statsmodels==0.9.0=py37h452e1ab_0- defaults/win-64::_anaconda_depends==5.3.1=py37_0
failedCondaMemoryError: The conda process ran out of memory. Increase system memory and/or try again.

conda update conda,conda update numpy,conda update --name base conda,在cat(自建虚拟环境)和base里都报错:

CondaMemoryError: The conda process ran out of memory. Increase system memory and/or try again.

还有的朋友建议:

conda update conda -c conda-canary

但是仍旧不行,报错如下,和前面的报错也一样。 

CondaMemoryError:conda 进程内存不足答案 - 爱码网

更新anaconda的版本也报同样的错:

(base) PS E:\matlab> conda update anaconda
Collecting package metadata (repodata.json): done
Solving environment: \
The environment is inconsistent, please check the package plan carefully
The following packages are causing the inconsistency:- defaults/win-64::anaconda==custom=py37_1- https://repo.anaconda.com/pkgs/main/win-64::bkcharts==0.2=py37_0- https://repo.anaconda.com/pkgs/main/win-64::blaze==0.11.3=py37_0- https://repo.anaconda.com/pkgs/main/win-64::bokeh==0.13.0=py37_0- https://repo.anaconda.com/pkgs/main/win-64::dask==0.19.1=py37_0- https://repo.anaconda.com/pkgs/main/win-64::numpydoc==0.8.0=py37_0- https://repo.anaconda.com/pkgs/main/win-64::odo==0.5.1=py37_0- https://repo.anaconda.com/pkgs/main/win-64::seaborn==0.9.0=py37_0- https://repo.anaconda.com/pkgs/main/win-64::sphinx==1.7.9=py37_0- https://repo.anaconda.com/pkgs/main/win-64::spyder==3.3.1=py37_1- https://repo.anaconda.com/pkgs/main/win-64::statsmodels==0.9.0=py37h452e1ab_0- defaults/win-64::_anaconda_depends==5.3.1=py37_0
failedCondaMemoryError: The conda process ran out of memory. Increase system memory and/or try again.

找到好久找到了一个解决方案:

 https://github.com/conda/conda/issues/10751

解决方案

说到最后实在是稀松平常,我检查了一下程序逻辑。我发现在传递参数的过程中。

  File "E:\matlab\CHB-MIT-DATA\epilepsy_eeg_classification\preprocessing.py", line 117, in eeg_preprocessing
    res = pd.DataFrame(res, columns=column_names)
  File "E:\matlab\CHB-MIT-DATA\epilepsy_eeg_classification\preprocessing.py", line 334, in <module>

虽然报错在117处,但是,实际上在传递的这两个数据处,通过debug的方式,发现获取的数据的列数要大于实际列数。那是因为,信号的channel变化的,而不是23个固定不变的,所以,只需要把这个固定的23改为,len(channel)就能获取到具体的数字。

        for i in range(23):features.extend(eeg_features(temp[i]).tolist())

改为

        for i in range(len(channels)):features.extend(eeg_features(temp[i]).tolist())

即可。

需要特别说明的是,conda创建的虚拟环境不要胡乱删除,否则会报很多错,你可以根据报错内容删除一些相应的文件,但是不能删除过多的文件。否则会报无数的错误。

这会让你非常头疼。这三篇文章都是我删错文件报错的。

 你会发现你无意中删除了一些包的依赖,这就麻烦了。

另外,我的程序报错或许和你的虽然报错一样,但是具体错误的地方不一样,这个时候,你就要好好检查你生成的数据和列名是否符合情况。可以参考这篇文章来看看,或许能够解决你的错误:

已解决ValueError: 4 columns passed, passed data had 2 columns_无 羡ღ的博客-CSDN博客

参考文章

Packagenotinstallederror:未安装在前缀中 - IT宝库

http://www.lryc.cn/news/1612.html

相关文章:

  • 166_技巧_Power BI 窗口函数处理连续发生业务问题
  • 电子科技大学人工智能期末复习笔记(五):机器学习
  • 使用DDD指导业务设计的总结思考
  • 面试官问:如何确保缓存和数据库的一致性?
  • 16.数据库Redis
  • 【Redis高级-集群分片】
  • CSDN - CSDN27题解
  • docker拉取mysql
  • 在Linux上安装Python3
  • 23 种设计模式的通俗解释,看完秒懂
  • 如何做好需求管理?经验方法、模型、工具
  • 怎么用期货做风险对冲(如何利用期货对冲风险)
  • C++标准模板库type_traits源码剖析
  • Python获取公众号(pc客户端)数据,使用Fiddler抓包工具
  • Maven进阶
  • AXI实战(一)-为AXI总线搭建简单的仿真测试环境
  • 数据库管理-第五十六期 监控(20230210)
  • 测试开发,测试架构师为什么能拿50 60k呢需要掌握哪些技能呢
  • Miniblink 入门
  • [python入门㊷] - python存储数据
  • Little Fighter:旺角——NFT 系列来袭!
  • 基础篇:01-微服务概述
  • TC358775XBG替代方案|完美替代 TC358775XBG替代方案|低BOM成本DSI转LVDS方案CS5518
  • Android开发
  • virtualbox虚拟机导入到vmware esxi虚拟机
  • 如何使用命名空间管理C++代码
  • 海思3559:BT656调试笔记
  • reactor之hooks
  • 单片AR眼镜Monocle揭秘:基于反射棱镜,重15g续航1小时
  • 计算机视觉框架OpenMMLab开源学习(五):目标检测实战