简体   繁体   中英

Can't filter based on boolean array on numpy array python

I have this simple code in python:

 >>> farray
 array([ 34.646433,  34.642292,  34.645295,  34.645938,  34.647517,
    34.646254,  34.640245])
 >>> is_ok
 0    False
 1    False
 2    False
 3    False
 4    False
 5    False
 6    False
 dtype: bool

Now if I do this:

 >>>farray[is_ok]
array([ 34.646433,  34.646433,  34.646433,  34.646433,  34.646433,
    34.646433,  34.646433])

When I tested my code it worked and the output was []. However I've used it on a different machine and it doesn't work. From what I've seen, both machines have 3.6.3 python. I also get a warning:

D:\Anaconda3\lib\site-packages\ipykernel_launcher.py:1: FutureWarning: in 
the future, boolean array-likes will be handled as a 
boolean array index
"""Entry point for launching an IPython kernel.

Can someone please explain to me what's happening? I'm not very familiar with python.

不同的numpy版本,更新后需要重新启动内核

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM