I have an array of tuples (from prev processing of a structured array, but the filed info was lost).
>>> arr
[(0.109, 0.5), (0.109, 0.55), (0.109, 0.6)]
>>>
I need to extract the column vectors for first and second column.
Using two indices with fixed values works OK, but wildcarding the row fails.
>>> arr[0][1]
0.5
>>> arr[*][1]
File "<stdin>", line 1
arr[*][1]
^
SyntaxError: invalid syntax
>>>
Your feedback is appreciated.
To get a list that contains the first element of each tuple:
[elem[0] for elem in arr]
...and the second element:
[elem[1] for elem in arr]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With