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

The Archive Base Latest Questions

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

the code below was written to check for NaN values in a Python ND-Array

  • 0

the code below was written to check for NaN values in a Python ND-Array column. If there is a NaN in either temparr1 or temparr2, we remove the corresponding row from both of them. The problem is, it doesn’t seem to work. Could you please help me out?

        temparr1=arr[index[indexkey]][:]// We get a column from arr, an nd-array of size 0 to 9470
        temparr2=arr[index[secondIndexKey]][:]// Same as above, but with the next column
        rwc=range(0,len(arr)) We get a bit vector of a sort to check.
        for i in range(0,len(arr)):
            if(isnan(temparr1[i]) or isnan(temparr2[i]) ):
                rwc = rwc[:i-1]+rwc[i+1:] // Remove the value from the bit Vector for a NaN value in the arrays.
                print i
        temparr1 = []
        temparr2 = []
        for i in rwc:
            temparr1.append(arr[index[indexkey]][i])
            temparr2.append(arr[index[secondIndexKey]][i])// Extract the data for the corresponding values in RWC and get them into the temparrs.

Can someone tell me why it is not working, why I still am getting NaNs??

An Array looks like : [99,242,122,nan,42,nan,414,…………….]

  • 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-17T20:25:13+00:00Added an answer on June 17, 2026 at 8:25 pm

    After rwc=range(0,len(arr)) you have len(rwc)=len(arr), so in the line rwc = rwc[:i-1]+rwc[i+1:] you expect that i is the same index for rwc and arr.

    However after you do rwc = rwc[:i-1]+rwc[i+1:] you get a list of smaller length (len(rwc) = len(arr) -2), so during next iteration you start removing wrong elements from your list.

    Also I suspect that you intended to do rwc = rwc[:i]+rwc[i+1:], which is another bug

    As far as I understand you tried to do something like this:

    X=arr[index[indexkey]]
    Y=arr[index[secondIndexKey]]
    
    temparr1 = []
    temparr2 = []
    for i in range(len(X)):  #I assume len(X)=len(Y)
        if not (isnan(X[i]) or isnan(Y[i])):
            temparr1.append(X[i])
            temparr2.append(Y[i])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written the code below to check the elements of array. I got
I have written below code to check for blank value in my textbox but
I've written the below code to set filepath column in my table as 'F:\DataMigration\Wise\DELTA_20121008\Attachments\SR\SR_1.txt'
The code below is written in php: $user = addslashes($_POST['user']); $pwd = addslashes($_POST['pwd']); $query
Hi I have written below code function unique(th){ var obj = {}; for(var i
I am trying to fetch wcf service from jquery. I have written below code
I have written grammar for a language (sample code below) //this is a procedure
I have written a very simple WCF service, that worked fine (code below), then
I have written a MapReduce program, code is below: import java.io.IOException; import java.util.Iterator; import
Which code snippet will give better performance? The below code segments were written in

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.