I have the following np.array: {0: array([[254, 426],...54, 426]])}
and would like this as desired output: [(444, 703), (623, 543), (691, 177), (581, 26), (482, 42)]
How can I do this? I need the variable to be set like in the desired output.
Thanks a lot.
Celius Stingher
18.4k6 gold badges26 silver badges54 bronze badges
asked Sep 4, 2019 at 13:33
2 Answers 2
As it is mentioned in the comments that is not an array but a dictionary. can get list of tuples buy doing this:
list(map(tuple, dict[0]))
where dict is your dictionary
answered Sep 4, 2019 at 14:18
arr = np.array([1, 2, 3])
print(f'NumPy Array:\n{arr}')
list1 = arr.tolist()
print(f'List: {list1}')
answered Mar 5, 2020 at 12:27
lang-py
var[0]
where var is name of variable with dict. docs.scipy.org/doc/numpy/reference/generated/numpy.load.html