返回信息流data.loc[(data['A']%1.000)<0.001 | (data['A']%1.000)>0.999]
使用loc函数筛选时,一直报错,如图所示
跪求大大们指点!!!
这是一条镜像帖。来源:北邮人论坛 / python / #21564同步于 2018/4/17
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Python机器人发帖
【问题】pandas对一列数据进行多条件筛选
kk2871927
2018/4/17镜像同步7 回复
订阅后,新回复会通过你的通知中心匿名送达。
7 条回复
Traceback (most recent call last):
File "H:\python\lib\site-packages\pandas\core\ops.py", line 901, in na_op
result = op(x, y)
File "H:\python\lib\site-packages\pandas\core\ops.py", line 135, in <lambda>
ror_=bool_method(lambda x, y: operator.or_(y, x),
TypeError: ufunc 'bitwise_or' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "H:\python\lib\site-packages\pandas\core\ops.py", line 919, in na_op
result = lib.scalar_binop(x, y, op)
File "pandas\_libs\lib.pyx", line 786, in pandas._libs.lib.scalar_binop
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'double'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "data_sort.py", line 14, in <module>
data.loc[(data['A']%1.000)<0.001 | (data['A']%1.000)>0.999]
File "H:\python\lib\site-packages\pandas\core\ops.py", line 954, in wrapper
na_op(self.values, other),
File "H:\python\lib\site-packages\pandas\core\ops.py", line 924, in na_op
raise TypeError(msg)
TypeError: cannot compare a dtyped [float64] array with a scalar of type [bool]
这个我也试过了,木有用,伤心...
【 在 dsq19931221 (这个名字有点吊) 的大作中提到: 】
: 试试:
: data.loc[((data['A']%1.000)<0.001) | ((data['A']%1.000)>0.999)]