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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:14:27+00:00 2026-06-18T01:14:27+00:00

I have a 2D numpy array A of (60,1000) dimensions. Say, I have a

  • 0

I have a 2D numpy array A of (60,1000) dimensions.
Say, I have a variable idx=array([3,72,403, 512, 698]).

Now, I want to mask all the elements in the columns specified in idx. The values in these columns might appear in other columns but they shouldn’t be masked.

Any help would be appriciated.

  • 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-18T01:14:28+00:00Added an answer on June 18, 2026 at 1:14 am
    In [22]: A = np.random.rand(5, 10)
    
    In [23]: idx = np.array([1, 3, 5])
    
    In [24]: m = np.zeros_like(A)
    
    In [25]: m[:,idx] = 1
    
    In [26]: Am = np.ma.masked_array(A, m)
    
    In [27]: Am
    Out[27]: 
    masked_array(data =
     [[0.680447483547 -- 0.290757600047 -- 0.0718559525615 -- 0.334352145502
      0.0861242618662 0.527068091963 0.136280743038]
     [0.729374999214 -- 0.76026650048 -- 0.656082247985 -- 0.492464543871
      0.903026937193 0.0792660503403 0.892132409419]
     [0.0845266821684 -- 0.838838594048 -- 0.396344231382 -- 0.703748703373
      0.380441396691 0.010521007806 0.344945867845]
     [0.7501401585 -- 0.0685427000113 -- 0.587100320511 -- 0.780160645327
      0.276328587928 0.0665949459004 0.604174142611]
     [0.599926798275 -- 0.686378805503 -- 0.776940069716 -- 0.0452833614622
      0.598622591094 0.942843765543 0.528082379918]],
                 mask =
     [[False  True False  True False  True False False False False]
     [False  True False  True False  True False False False False]
     [False  True False  True False  True False False False False]
     [False  True False  True False  True False False False False]
     [False  True False  True False  True False False False False]],
           fill_value = 1e+20)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A toy-case for my problem: I have a numpy array of size, say, 1000:
Let's say I have an array of zeros: a = numpy.zeros(1000) I then introduce
I have a numpy array like this a = np.array(1) Now if I want
I have a numpy array A such that A.shape[axis] = n+1. Now I want
I have a NumPy array [1,2,3,4,5,6,7,8,9,10,11,12,13,14] and want to have an array structured like
I have a numpy array x, dimensions = (20, 4), in which only the
I have a numpy array of floats/ints and want to map its elements into
I have a numpy array, a , a.shape=(48,90,144) . I want to take the
I have a numpy array of dimension (48, 366, 3) and I want to
I have an numpy array of form a = [1,2,3] which I want to

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.