I am reshaping a 1D array into 3D using the following. It works fine but it throws an error when x
is 7267. I understand that it is not possible to slice an odd number as an int without losing some values. Would appreciate any solution to this.
code
x = 7248
y= 24
A = np.arange(x)
A.reshape(int(x/y),y,1).transpose()
output
array([[[ 0, 24, 48, ..., 7176, 7200, 7224],
[ 1, 25, 49, ..., 7177, 7201, 7225],
[ 2, 26, 50, ..., 7178, 7202, 7226],
...,
[ 21, 45, 69, ..., 7197, 7221, 7245],
[ 22, 46, 70, ..., 7198, 7222, 7246],
[ 23, 47, 71, ..., 7199, 7223, 7247]]])
question from:
https://stackoverflow.com/questions/65837066/reshape-list-with-column-elements 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…