Pandas: calculate average from numpy array for each row in column
I have a pandas dataframe, df , that contains columns where each row contains a numpy array of different sizes, eg.
column A 0 np.array([1,2,3]) 1 np.array([1,2,3,4]) 2 np.array([1,2])
Is there a built-in pandas function that will return the average of each array, i.e. rows, for the whole column? Something like:
But it works on every line. Thanks for any help.
source to share