尝试使用 np.loadtext 导入文件时,我不断收到错误“ValueError:第 1 行有 2 列的列索引 2 无效”

问题描述 投票:0回答:1

尝试使用 np.loadtext 导入文件时,我不断收到错误“ValueError:第 1 行有 2 列的列索引 2 无效”。

This is the file that I am trying to import, it goes on for several more rows

这是我当前用于尝试导入文件的代码。

from google.colab import drive
drive.mount('/content/drive')

%matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt


evo0_8f = '/content/drive/MyDrive/HR-Diagram/evo_0.8.txt'
evo0_8 = np.loadtxt(evo0_8f, skiprows=2, usecols=(1,2))
python file import valueerror
1个回答
0
投票

各列从零开始编号。你需要

usecols=(0,1)

© www.soinside.com 2019 - 2024. All rights reserved.