运行此代码时,出现以下错误:
if products.code == 'attendance':
print('Attendance Product Detected')
else:
print('Attendance Not Detected')
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
但是,当我在控制台中键入此命令时,它工作正常:
products.code == 'attendance'
Out:
0 True
Name: code, dtype: bool
如何解决此问题,以便if和else函数起作用?
答案 0 :(得分:0)
尝试使用.item() 并尝试:
spring.datasource.url=jdbc:h2:mem:testdb;INIT=create domain if not exists jsonb as text;MODE=PostgreSQL"
答案 1 :(得分:0)
我找到了另一种方法,但是我不知道它是否有效。 我看到了您的产品。代码==“出勤”结果就像一个DataFrame。
if (products.code != 'attendance').empty:
print('Attendance Product Detected')
else:
print('Attendance Not Detected')