1

I have an array (called "attractors") which looks like this:

[['0000000000' '0.0' '0.0']
 ['0000000001' '0.0' '1.0']
 ['0000000010' '0.0' '2.0']
...........................

I want to create new array which contains all rows where the third column was 0 in the original array. I try the following:

print(attractors[attractors[: , 2] == 0][: , 0])

but I receive the following error:

            json export to visualize state transition diagram with compression
 - tests.py:247: FutureWarning: elementwise comparison failed; 
    returning scalar instead, but in the 
        future will perform elementwise comparison 
              print(attractors[attractors[: , 2] == 0][: , 0])

If I put brackets on the condition, like this:

print(attractors[attractors[: , 2] == "0"][: , 0])

then the error does not appear, but the results is not what I expected (only empty brackets [])

2 Answers 2

1

isn't it because you have strings of format '0.0'

so maybe you should do something like this

print(attractors[attractors[: , 2] == '0.0'][: , 0])
Sign up to request clarification or add additional context in comments.

1 Comment

It works great, but the outcome is an array with numbers inside. How can I make it to have outcome as an array with strings inside (i.e. in the same format as in the primary array)
1

You can use list comprehension:

[x for x in attractors if x[2] == 0]

If it's a string you can change the equality to == '0.0'

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.