相关疑难解决方法(0)

Python Pandas:如何在读取文件时跳过列?

我的表格格式如下:

foo - bar - 10 2e-5 0.0 some information
quz - baz - 4 1e-2 1 some other description in here
Run Code Online (Sandbox Code Playgroud)

当我用熊猫打开它时:

a = pd.read_table("file", header=None, sep=" ")
Run Code Online (Sandbox Code Playgroud)

它告诉我:

CParserError: Error tokenizing data. C error: Expected 9 fields in line 2, saw 12
Run Code Online (Sandbox Code Playgroud)

我基本上喜欢的是类似于skiprows选项的东西,它允许我做类似的事情:

a = pd.read_table("file", header=None, sep=" ", skipcolumns=[8:])
Run Code Online (Sandbox Code Playgroud)

我知道我可以重新格式化这个表awk,但我想知道是否存在Pandas解决方案.

谢谢.

python pandas

13
推荐指数
1
解决办法
4万
查看次数

标签 统计

pandas ×1

python ×1