CHH3213 / Note-Ubuntu_CHH3213

ubuntu系统CHH3213上做的笔记
0 stars 0 forks source link

1. python数组展平成一列 #1

Open CHH3213 opened 3 years ago

CHH3213 commented 3 years ago

原来为7行3列:

[[ 0.00000000e+00  0.00000000e+00 -2.69499700e-12]
 [-2.10534030e-01 -3.15565144e+00  6.83704029e+00]
 [-2.13012756e-01  2.83851793e+00  6.81062238e+00]
 [ 4.99991534e+00  4.99929875e+00  5.99999612e-02]
 [-5.00008466e+00  4.99929954e+00  5.99956080e-02]
 [-5.00008463e+00 -5.00070098e+00  5.99999612e-02]
 [ 4.99991537e+00 -5.00070019e+00  5.99956080e-02]]

使用展平命令:

np.array(train_data['pos'][0]).flatten()

变成1行21列:

[ 0.00000000e+00  0.00000000e+00 -2.69499700e-12 -2.10534030e-01
 -3.15565144e+00  6.83704029e+00 -2.13012756e-01  2.83851793e+00
  6.81062238e+00  4.99991534e+00  4.99929875e+00  5.99999612e-02
 -5.00008466e+00  4.99929954e+00  5.99956080e-02 -5.00008463e+00
 -5.00070098e+00  5.99999612e-02  4.99991537e+00 -5.00070019e+00
  5.99956080e-02]