0

i have 3 array a and b with the same size

a= [1,20,0,3,9,9,9,55]
b= [1,5,6,9,9,9,9,55]

i need to delete the element 0 from a and delete the element in the same index in the array b will look like this:

    a= [1,20,3,9,9,9,55]
    b= [1,5,9,9,9,9,55]



import numpy as np
import math
a = np.array([1, 0,3])
b = np.array([5, 6,9])


c= np.vstack((a,b)).T
c= c[(c[:,0]<>0)]
k= c[:,0]
f= c[:,1]
r= math.sqrt(np.mean(np.power(((k - f) / k),2)))
r

my code is working but i did not like it do you have any other propositions ?

1

1 Answer 1

1

if you have a, b, c as numpy arrays

valid_idx = (a != 0)
b = b[valid_idx]
c = c[valid_idx]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.