I'd like to store a 3D-numpy array in a column of a dataframe.
df = pd.DataFrame({"nodes": list(range(1, 4))})
df = df.set_index("nodes")
df[0] = list(range(1, 6, 2))
df[1] = [10,20,30]
>>> df
0 1
nodes
1 1 10
2 3 20
3 5 30
Example for numpy-array:
test = np.array([[[1,2,3],
[4,5,6]],
[[10,20,30],
[40,50,60]],
[[0,1,0],
[-1,-1,-1]]])
What i would like to have is:
>>> df
0 1 2
nodes
1 1 10 [[1,2,3],[4,5,6]]
2 3 20 [[10,20,30],[40,50,60]]
3 5 30 [[0,1,0],[-1,-1,-1]]
How can i add the 3d-array to a column of the existing dataframe?
question from:
https://stackoverflow.com/questions/65848040/store-3d-array-in-a-pandas-dataframe-column 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…