Reputation: 1653
I have an array that looks like this:
sample_array = [(1,3),(2,2),(3,1)]
I need to find the average to output :
>> [2,2]
I tried the code below
np.average(left_lane)
but it returns
>> 2.0
How can I make it so that it returns two values without having to loop?
Upvotes: 2
Views: 2819
Reputation: 16434
You can use:
a = np.array(sample_array)
np.average(a, axis=0)
Or:
a.mean(0)
Upvotes: 8