我有这样一个df:
Car | Color | Year | Price
VW | blue | 2014 | 20,000
Audi| red | 2017 | 30,000
我用如果这个表不是我真正的df,只是需要一个想法。你知道吗
我需要的车辆价格,如果选择奥迪让我们说。你知道吗
我在字符串中寻找s子字符串,但我只需要找到子字符串所在行中一个特定列的开销。你知道吗
我正在使用:
for x in cars['Car']:
if "Audi" in x:
#Just need the row in column 'Price'
print(??)
您可以使用带有
iterrows
的for
循环来检查任何行的Car
是否包含Audi
。你知道吗可以对pandas使用布尔索引。你知道吗
要分解它:
不要进行字符串比较您可以直接使用
pd.groupby()
函数,如下所示:输出:
相关问题 更多 >
编程相关推荐