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

  • SEARCH
  • Home
  • 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 8677867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:34:26+00:00 2026-06-12T20:34:26+00:00

here we go again: I would like a function much like filter , but

  • 0

here we go again:

I would like a function much like filter, but it ought to return arguments rather than values:

data = numpy.array([0.0, 35., 2., 44., numpy.pi, numpy.sqrt(2.)])
args_pass_A = some_sort_of_f(lambda x: x<4., data)
print(args_pass_A)
[0, 2, 4, 5]
args_pass_B = some_sort_of_f(lambda x: x>=44., data)
print(args_pass_B)
[3]

I tried to lookup in scipy.stats and scipy.stats.mstats, where I’ve been recently directed towards mquantiles (thank you aganders3). Does this ring any bell? I also tried to lookup in numpy documentation, but with no luck.

Thank you in advance.

  • 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-12T20:34:27+00:00Added an answer on June 12, 2026 at 8:34 pm

    For this case I’d just use where [docs]:

    >>> import numpy
    >>> data = numpy.array([0.0, 35., 2., 44., numpy.pi, numpy.sqrt(2.)])
    >>> data
    array([  0.        ,  35.        ,   2.        ,  44.        ,
             3.14159265,   1.41421356])
    >>> numpy.where(data < 4)
    (array([0, 2, 4, 5]),)
    >>> numpy.where(data > 44.)
    (array([], dtype=int64),)
    >>> numpy.where(data >= 44.)
    (array([3]),)
    

    Note that what you’re looking for is really the first element of the returned tuple:

    >>> numpy.where(data < 4)[0]
    array([0, 2, 4, 5])
    

    and you can use these indices to index data again:

    >>> data[numpy.where(data < 4)[0]]
    array([ 0.        ,  2.        ,  3.14159265,  1.41421356])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have done an Accordion style jQuery function which works lovely, but would like
Here we go again , searched and tried myself but none of the online
So, I seem to ask hard questions but here I go again. I have
I followed this guide here perfectly and have gone through it again but when
As this is my first post here, I would like to thank all of
I'm trying to store randomly generated dice values in some data structure, but don't
I'm using jquerys slideToggle method and would like to add a callback function that
I would like to push data from mysql db to div every x seconds.
Rookie C++ Programmer here again I'm using VC++ VS2008 and making an attempt at
Alright, here I am again trying to write code from scratch and I can't

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.