Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7935171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:50:35+00:00 2026-06-03T21:50:35+00:00

For example: I have a = np.array([123, 412, 444]) and b = np.array([123, 321])

  • 0

For example: I have a = np.array([123, 412, 444])
and b = np.array([123, 321])

I want to know if a contains all the elements in b. Is there a simple operation for this? In this case that would not be true.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:50:36+00:00Added an answer on June 3, 2026 at 9:50 pm

    You can use set difference to determine what you are looking for. Numpy has a built-in function called numpy.setdiff1d(ar1, ar2):

    Return the sorted, unique values in ar1 that are not in ar2.

    Example for your case:

    >>> a = np.array([123, 412, 444])
    >>> b = np.array([123, 321])
    >>> diff = np.setdiff1d(b, a)
    >>> print diff
    array([321])
    >>> if diff.size:
    >>>    print "Not passed"
    

    So for your case, you would do a set difference you would subtract a from b and obtain an array with elements in b which are not in a. Then you can check if that was empty or not. As you can see, the output is 312, which is an entry present in a but not in b; the length of it is now larger then zero, therefore there were elements in b which were not present in a.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of integers. For example: array = [123,321,12389] Is there any
For example i have an array like this: $test= array(0 => 412, 1 =>
I have the array: example = ['foo', 'bar', 'quux'] I want to iterate over
For example I have an array with about 10 elements in it. std::deque<int> d;
For example I have array of (x,y) points and I want to organize them
I have an array with x number of elements and want to print out
Here's the problem. I ,for example,have a string 2500.Its converted from byte array into
I have an array of strings(as shown in example). I just wish to find
I have this array, for example (the size is variable): x = [1.111, 1.122,
I have an array of 4 characters, for example: char char_array[10]; char_arr[0] = 'a';

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.