Find avg value from list having single element
Solution 1:
Do this:
import numpy as np
np.mean(list, axis=1)[0] # the list here refers to list you've created
This will return:
array([7., 8., 9.])
Solution 2:
Quick solution:
import numpy as np
np.mean(list[0], axis=0)
Bugs and cautions on your example though:
- NEVER name your variable is
list
,dict
or other built-in functions/types/keywords. Ideally use phrases relevant to the content, and meaningless varname is still better than overriding default functions. -
import numpy as np
rather thanimport numpy
. Or you can simplyimport numpy
and then write the lines afterwards withnumpy.array
instead ofnp.array
.