小编Y.Z*_*Y.Z的帖子

将两个numpy数组转换为dataframe

我想将两个numpy数组转换为DataFrame包含两列的数组.第一个numpy数组'images'是有形的102, 1024.第二个numpy数组'label'是有形的(1020, )

我的核心代码是:

images=np.array(images)
label=np.array(label)
l=np.array([images,label])
dataset=pd.DataFrame(l)
Run Code Online (Sandbox Code Playgroud)

但事实证明这是一个错误说:

ValueError: could not broadcast input array from shape (1020,1024) into shape (1020)
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能将这两个numpy数组转换为一个数据帧中的两列?

python arrays numpy dataframe pandas

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

arrays ×1

dataframe ×1

numpy ×1

pandas ×1

python ×1