【发布时间】:2020-07-15 07:24:44
【问题描述】:
我有一个 pandas 数据框,其中一列包含列表:
import pandas as pd
import numpy as np
(
pd.DataFrame({
"x": [[1, 2], [3, 4], [5, 6]]
)}
.assign(x = lambda data: data.x.apply(np.array)) # convert lists into numpy arrays
.to_numpy()
.shape # returns (3, 1) when I was hoping for a (3,1,2)
)
我想将这些数据作为 3D 数组传递到 tensorflow,但首先我需要能够从中得到正确的形状。
非常感谢!
【问题讨论】:
-
@JvdV,我不是 100% 确定,但我认为应该是 (3,1,2):3 行,1 列,2 维
标签: python pandas numpy tensorflow