Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/324.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 我怎么看一排熊猫?_Python_Pandas - Fatal编程技术网

Python 我怎么看一排熊猫?

Python 我怎么看一排熊猫?,python,pandas,Python,Pandas,我对蟒蛇熊猫相当陌生。很抱歉问了一个很简单的问题。但我正试图瞄准街上所有的餐馆 这不是针对它的方法吗: commonwealth = df[df['Street'] == 'Commonwealth AV'] Restaurant Number Street a 700 Commonwealth AV b 300 Faneuil Hall ST c 440 Commonwealth AV 然而,

我对蟒蛇熊猫相当陌生。很抱歉问了一个很简单的问题。但我正试图瞄准街上所有的餐馆

这不是针对它的方法吗:

commonwealth = df[df['Street'] == 'Commonwealth AV']

 Restaurant Number Street
    a          700    Commonwealth AV
    b          300    Faneuil Hall ST
    c          440    Commonwealth AV
然而,我没有得到任何回报


此外,就在我锁定“Street”之前,我实际上将地址分为“Street”和“Number”。我不确定这是否会改变任何事情。

正如其他人所指出的,您的字符串中有一些空白。这方面的线索是,街道名称显示在与列名的偏移位置。试一试

df['Street'] = df['Street'].apply(lambda x: x.strip())
清除所有空白。然后

df[df['Street'] == 'Commonwealth AV']


你应该得到街道所在的地方的切片
联邦AV

你说没有任何回报是什么意思?df的内容是什么?执行该行后,commonwealth的内容是什么?df的内容包括“餐厅”、“号码”、“街道”、“城市”、“地址”、“Violstatus”等。当我执行commonwealth时,我得到的len count为0。您粘贴在此处的代码没有明显错误。如果不知道数据帧中有什么(意味着其中的所有元素),就不可能检查值中的尾随空格。您发布的内容看起来很好。就像@PaulH说的,检查空格。街道名称前可能有一个空格。
df.loc[df['Street'] == 'Commonwealth AV', :]