Pandas一直都是我处理数据的首选库,最近在处理Boston的房价数据,当我要把房间数大于等于5小于4的数据筛选出来的时候一直搞不定,查了谷歌之后从StackOverflow上一个Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()的问题找到了答案,刚开始的时候我是这么做的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
In [36]: data[data.RM >= 5 and data.RM < 6] --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-36-c9db36aa7999> in <module>() ----> 1 data[data.RM >= 5 and data.RM < 6] /home/qiuwei/py2/local/lib/python2.7/site-packages/pandas/core/generic.pyc in __nonzero__(self) 915 raise ValueError("The truth value of a {0} is ambiguous. " 916 "Use a.empty, a.bool(), a.item(), a.any() or a.all()." --> 917 .format(self.__class__.__name__)) 918 919 __bool__ = __nonzero__ ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). |