如何解决使用 Iris 数据集的最后 20 个在 python 中进行断言
我正在尝试编写一个 assert 语句来证明我提取的 iris 数据集的 Virginica 子集的最后 20 行确实等于 'Virginica'
到目前为止我尝试过的:
assert (last_20['variety']) == 'Virginica')
但我收到以下错误:
ValueError Traceback (most recent call last)
<ipython-input-86-9498f7345325> in <module>
8 # test that the subset has the class Virginica
9
---> 10 assert ((last_20['variety']) == 'Virginica')
11
12
~/anaconda3/lib/python3.8/site-packages/pandas/core/generic.py in __nonzero__(self)
1439 @final
1440 def __nonzero__(self):
-> 1441 raise ValueError(
1442 f"The truth value of a {type(self).__name__} is ambiguous. "
1443 "Use a.empty,a.bool(),a.item(),a.any() or a.all()."
ValueError: The truth value of a Series is ambiguous. Use a.empty,a.any() or a.all().
我尝试像之前建议的那样删除括号,但仍然出现错误。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。