我有以下数据集。
url, team1, team2, win_toss, bat_or_bowl, outcome, win_game, date,day_n_night, ground, rain, duckworth_lewis, match_id, type_of_match
"espncricinfo-t20/145227.html","Western Australia","Victoria","Victoria","bat","Western Australia won by 8 wickets (with 47 balls remaining)","Western Australia"," Jan 12 2005","1"," Western Australia Cricket Association Ground,Perth","0","0","145227","T20"
"espncricinfo-t20/212961.html","Australian Institute of Sports","New Zealand Academy","New Zealand Academy","bowl","Match tied",""," Jul 7 2005 ","0"," Albury Oval, Brisbane","0","0","212961","T20"
"espncricinfo-t20/216598.html","Air India","New South Wales","Air India","bowl","Air India won by 7 wickets (with 5 balls remaining)","Air India"," Aug 19 2005 ","0"," M Chinnaswamy Stadium, Bangalore","0","0","216598","T20"
"espncricinfo-t20/216620.html","Karnataka State Cricket Association XI","Bradman XI","Bradman XI","bowl","Karnataka State Cricket Association XI won by 33 runs","Karnataka State Cricket Association XI"," Aug 20 2005 ","0"," M Chinnaswamy Stadium, Bangalore","0","0","216620","T20"
"espncricinfo-t20/216633.html","Chemplast","Bradman XI","Chemplast","bat","Bradman XI won by 6 wickets (with 13 balls remaining)","Bradman XI"," Aug 20 2005 ","0"," M Chinnaswamy Stadium, Bangalore","0","0","216633","T20"
这是来自python控制台:
**
>>> import pandas as pd
>>> df = pd.read_csv("sample.txt" , quotechar = '\"')
>>> df.shape
(9, 14)
>>> df.columns
Index([u'url', u' team1', u' team2', u' win_toss', u' bat_or_bowl',
u' outcome', u' win_game', u' date', u' day_n_night', u' ground',
u' rain', u' duckworth_lewis', u' match_id', u' type_of_match'],
dtype='object')
>>> df.url.head()
0 espncricinfo-t20/145227.html
1 espncricinfo-t20/212961.html
2 espncricinfo-t20/216598.html
3 espncricinfo-t20/216620.html
4 espncricinfo-t20/216633.html
Name: url, dtype: object
>>> df.team1.head()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/python27/lib/python2.7/site-packages/pandas/core/generic.py", line 2744, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'team1'
>>> df.iloc[1:2]
url team1 \
1 espncricinfo-t20/212961.html Australian Institute of Sports
team2 win_toss bat_or_bowl outcome \
1 New Zealand Academy New Zealand Academy bowl Match tied
win_game date day_n_night ground rain \
1 NaN Jul 7 2005 0 Albury Oval, Brisbane 0
duckworth_lewis match_id type_of_match
1 0 212961 T20
我们可以看到列team1存在,但我无法从Df中检索它。除了第一个,我收到所有列的错误。有人可以帮我找到问题!感谢