我正在学习bokeh
,并从真正的python那里学习a tutorial。
在一个教程中,它仅将排名数据集分为两个团队,并在下面产生结果。除了将我的“获胜”列转换为NaN
之外,我得到的结果完全相同。任何想法,为什么会这样
west_top_2 = standings[(standings['teamAbbr'] == 'HOU') | (standings['teamAbbr'] == 'GS')]\
.loc[:,['stDate','teamAbbr','gamewon']].sort_values(['teamAbbr','stDate'])
stDate teamAbbr gameWon
9 2017-10-17 GS 0
39 2017-10-18 GS 0
69 2017-10-19 GS 0
99 2017-10-20 GS 1
129 2017-10-21 GS 1
我的输出
stDate teamAbbr gamewon
9 2017-10-17 GS NaN
39 2017-10-18 GS NaN
69 2017-10-19 GS NaN
99 2017-10-20 GS NaN
129 2017-10-21 GS NaN
答案 0 :(得分:0)
您的陈述中有错字,这是正确的:
west_top_2 = (standings[
(standings['teamAbbr'] == 'HOU') | (standings['teamAbbr'] == 'GS')
].loc[:, ['stDate', 'teamAbbr', 'gameWon']].sort_values(['teamAbbr','stDate']))
您的括号中缺少大写字母“ W”。