Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 子设置时,列的所有值都转换为NaN_Python_Pandas_Nan - Fatal编程技术网

Python 子设置时,列的所有值都转换为NaN

Python 子设置时,列的所有值都转换为NaN,python,pandas,nan,Python,Pandas,Nan,我正在学习bokeh,并学习真正的python 在教程中,它将排名数据集子集为两个团队,并生成以下结果。我得到了完全相同的结果,只是我的“赢得比赛”列被转换为NaN。你知道为什么会这样吗 west_top_2 = standings[(standings['teamAbbr'] == 'HOU') | (standings['teamAbbr'] == 'GS')]\ .loc[:,['stDate','teamAbbr','gamewon']].sort_values(['te

我正在学习bokeh,并学习真正的python

在教程中,它将排名数据集子集为两个团队,并生成以下结果。我得到了完全相同的结果,只是我的“赢得比赛”列被转换为
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

您的陈述中有一个拼写错误,这是正确的:

west_top_2 = (standings[
    (standings['teamAbbr'] == 'HOU') | (standings['teamAbbr'] == 'GS')
].loc[:, ['stDate', 'teamAbbr', 'gameWon']].sort_values(['teamAbbr','stDate']))

缺少括号和大写字母“W”。

gamewon应该是gamewon?好的。这真是一个愚蠢的错误。我应该在问之前仔细检查一下。谢谢你,这是我们中最好的!