我有一个文本文件,如下所示:
************************************************************************************************
English Premier Division - Saturday 25th May 2002
************************************************************************************************
================================================================================================
2001/2 Assists
================================================================================================
Pos Player Club Apps Asts
-------------------------------------------------------------------------
1st David Beckham Man Utd 29 15
2nd Dean Gordon Middlesbrough 30 (1) 11
3rd John Collins Fulham 32 11
4th Ryan Giggs Man Utd 32 11
5th Kieron Dyer Newcastle 33 10
6th Sean Davis Fulham 23 (1) 10
7th Damien Duff Blackburn 30 (3) 10
8th Alan Smith Leeds 23 (6) 9
9th Jesper Grønkjær Chelsea 34 9
我试图把它读成一个大熊猫数据帧,就像这样:
df = pd.read_table('assist1.txt',
sep='\s+',
skiprows=6,
header=0,)
此代码引发异常 - pandas.errors.ParserError: 标记数据时出错。C 错误:预期第 31 行中有 7 个字段,看到 8 个字段。
我想这是因为玩家的名字和姓氏之间的空格(应该是“玩家”列的值)。有没有办法做到这一点?
慕村9548890
喵喔喔
相关分类