Numpy Array of type Boolean

Source: Internet
Author: User

Returns an element that is greater than 10, given a list.

There are two ways to do this in Python. One method is loop traversal, the second method is to use the built-in function filter ()

  

  

In the array, there is an easier way. That is, the Boolean index

Boolean index:

A Boolean array of the same size is passed into the index, which returns an array of all the elements that correspond to the true position of the moth.

Make a cushion first.

  

  

So, here comes the point.

    

ARR>10 will determine each element in the array arr, returning a Boolean array.

Two-and or non-

1 Given a list, returns an element that is greater than 10 and is even.

  

Description

1) & is actually a bitwise-and concept

      

0101 =5

0110 =6

Add

0100 = 4 you got it!

2) & brackets on both sides because the,& operator has a higher precedence.

2 Given a list, returns an element that is greater than 10, or even. |

3 Given a list, returns an array of no greater than 10. ~

Numpy Array of type Boolean

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.