0

I have a dataframe transformed to a numpy array after scaling. Example: (let's say there is 1000 samples)

       [[ -3.12819390e-01  -1.92776011e-01  -5.86198203e-01 ...,   
           3.47114065e-01
           3.74794001e-01   2.89473684e-01]
        [ -7.99896504e-01  -8.35721640e-01  -8.70581173e-01 ...,   
           2.31696140e-01   2.36763880e-01   1.57894737e-01]
        [ -3.12819390e-01  -6.20289856e-02  -1.27139646e+00 ...,   

I have another numpy array 1D that has 1 or -1 (1000 samples also)

       [1 1 -1 ..., 1 -1 1]

How can I keep the samples(from first array) that has a 1(from the 2nd array) and remove the samples that has -1 ?

Thank you in advance !

1 Answer 1

2

You can use boolean indexing

arr1[:, arr2==1]
Sign up to request clarification or add additional context in comments.

2 Comments

Oh wait, I've got IndexError: index 298 is out of bounds for axis 1 with size 298
@hdatas The second array's length must be equal or less than dimension of indexed array along dimension 1;

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.