I have the following dataframe :
df = pd.DataFrame(
{'a':[np.array([1,2,3]),np.array([4,5,6])]
}
)
i want to have a numpy array like following extracted from the a column:
array([[1., 2., 3.],
[4., 5., 6.]])
i can do it like below:
for i, row in df.iterrows():
t_arr[i,:] = row["a"]
but i am looking for a solution without for loop. .values and to_numpy() don't return the desired results
values. It's a useful starting point for creating an answer. I expect it is an object dtype array with 2 array elements. In general they might differ in shape, but if they do match, they can then be joined into one array as demonstrated in the answers.