Skip to content
Advertisement

Select a string which has given value on a particular position

I have a ndarray which looks like this example:

JavaScript

I need to pick values from the second column, whose corresponding values in the first column matches particular criteria.

Example criteria: second and third position of the string (in first column) are equal to zero. If this is true, take a copy of the corresponding values in the second column and create new ndarray with them.

Advertisement

Answer

With a normal comprehension list, you can do:

JavaScript

You can change the criteria as required.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement