使用 NumPy 的 reshape 方法可以将 shape 为 (7486,) 的数组转换为 (7486, 1) 的形状。

import numpy as np

arr = np.array([1, 2, 3, 4, 5])
print(arr.shape)  # (5,)

arr_reshaped = arr.reshape((5, 1))
print(arr_reshaped.shape)  # (5, 1)

对于给定的 (7486,) 的数组,可以使用以下代码将其转换为 (7486, 1):

import numpy as np

arr = np.random.rand(7486)
print(arr.shape)  # (7486,)

arr_reshaped = arr.reshape((7486, 1))
print(arr_reshaped.shape)  # (7486, 1)
如何将 NumPy 数组 shape (7486,) 转换为 (7486, 1)

原文地址: https://www.cveoy.top/t/topic/mRjl 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录