You can first stack the arrays. Then you will be able to then handle them as numpy arrays:
import pandas as pd
import numpy as np
df = pd.DataFrame([[10, 10, 10, np.array([[1,2,3],[4,5,6],[7,8,9]])],
[12, 12, 12, np.array([[1,2,3],[4,5,6],[7,8,9]])],
[14, 14, 14, np.array([[1,2,3],[4,5,6],[7,8,9]])],],
columns=['x', 'y', 'z', 'matrix']
)
np.stack(df['matrix'])[:, 1,1]
output:
array([5, 5, 5])
example of assignment as new column:
>>> df['new'] = np.stack(df['matrix'])[:, 1,1]
>>> df
x y z matrix new
0 10 10 10 [[1, 2, 3], [4, 5, 6], [7, 8, 9]] 5
1 12 12 12 [[1, 2, 3], [4, 5, 6], [7, 8, 9]] 5
2 14 14 14 [[1, 2, 3], [4, 5, 6], [7, 8, 9]] 5
plotting
import plotly.express as px
df['matrix_center'] = np.stack(df['matrix'])[:, 1,1]
px.scatter_3d(df, x='x', y='y', z='z', color='matrix_center')
