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 6924137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:37:29+00:00 2026-05-27T10:37:29+00:00

One can use numpy ‘s extract function to match an element in an array.

  • 0

One can use numpy‘s extract function to match an element in an array. The following code matches an element 'a.' exactly in an array. Suppose I want
to match all elements containing '.', how would I do that? Note that in this case, there would be two matches. I’d also like to get the row and column number of the matches. The method doesn’t have to use extract; any method will do. Thanks.

In [110]: x = np.array([['a.','cd'],['ef','g.']])

In [111]: 'a.' == x
Out[111]: 
array([[ True, False],
       [False, False]], dtype=bool)

In [112]: np.extract('a.' == x, x)
Out[112]: 
array(['a.'], 
      dtype='|S2')
  • 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-05-27T10:37:30+00:00Added an answer on May 27, 2026 at 10:37 am

    You can use the string operations:

    >>> import numpy as np
    >>> x = np.array([['a.','cd'],['ef','g.']])
    >>> x[np.char.find(x, '.') > -1]
    array(['a.', 'g.'], 
          dtype='|S2')
    

    EDIT: As per request in the comments… If you want to find out the indexes of where the target condition is true, use numpy.where:

    >>> np.where(np.char.find(x, '.') > -1)
    (array([0, 1]), array([0, 1]))
    

    or

    >>> zip(*np.where(np.char.find(x, '.') > -1))
    [(0, 0), (1, 1)]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know one can use '<alt><shift>J' to create tags for a single code element
In numpy one can use the 'newaxis' object in the slicing syntax to create
One can use a command such as the following to substitute the word before
The following code: import numpy as p myarr=[[0,1],[0,6],[0,1],[0,6],[0,1],[0,6],[0,1],[0,6],[0,1],[0,6],[0,1],[0,6],[0,1],[0,6],[0,1],[0,6],[0,1],[0,6]] copy=p.array(myarr) p.mean(copy)[:,1] Is generating the following
I know one can use an index into an array to specify length of
What is the HTML element that one can use in order to insert source
In *nix systems one can use which to find out the full path to
What is the highest port number one can use?
What are some useful Oracle optimizations one can use for an Application that mostly
On the MSVC++ compiler, one can use the __int8 , __int16 , __int32 and

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.