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:

  1. 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.
  2. import numpy as np rather than import numpy. Or you can simply import numpy and then write the lines afterwards with numpy.array instead of np.array.