如何对nan值执行Python DataFrame布尔掩码

时间:2018-08-30 22:11:46

标签: python pandas

我有一个名为“ vp”的数据框,在某些行中,“ rev”是一个正浮点数,在其他行中,“ rev”不存在(NaN)。

如何将此数据框分成2个部分?我尝试过了

vpbook = vp[vp['rev'] > 0]              # works 
vpnonbook = vp[~vp['rev'] > 0]          # does not work 

无效的行将产生:

TypeError: ufunc 'invert' not supported for the input types, and the inputs 
could not be safely coerced to any supported types according to the casting 
rule ''safe''

该怎么做?

0 个答案:

没有答案