我想查看某個特定的字符串是否存在於我的數據框中的特定列中。檢查字符串是否在熊貓數據框中
,我發現了錯誤
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or 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"
誰你是嗎,@JohnGalt? –