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 columns

The 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_preprocessing
    res = 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
failed

CondaMemoryError: 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
failed

CondaMemoryError: 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
failed

CondaMemoryError: 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宝库

猜你喜欢

转载自blog.csdn.net/a1456123a/article/details/128927429