【发布时间】:2015-09-05 19:35:51
【问题描述】:
我想查看我的数据框中的特定列中是否存在特定字符串。
我收到了错误
ValueError:Series 的真值不明确。使用 a.empty, a.bool()、a.item()、a.any() 或 a.all()。
import pandas as pd
BabyDataSet = [('Bob', 968), ('Jessica', 155), ('Mary', 77), ('John', 578), ('Mel', 973)]
a = pd.DataFrame(data=BabyDataSet, columns=['Names', 'Births'])
if a['Names'].str.contains('Mel'):
print ("Mel is there")
【问题讨论】: