Tôi muốn xem liệu một chuỗi cụ thể có tồn tại trong một cột cụ thể trong khung dữ liệu của tôi hay không.Kiểm tra xem chuỗi có nằm trong khung dữ liệu gấu trúc không
Tôi nhận được lỗi
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"
Ai là bạn, @JohnGalt? –