简体   繁体   English

numpy 在空格后创建列

[英]numpy create column after blank space

I have numpy array of size (6214,1), which looks like this:我有大小为 (6214,1) 的 numpy 数组,如下所示:

图片

I would like to create a column after each blank space, but whatever I try I am not successful.我想在每个空格后创建一个列,但无论我尝试什么,我都不成功。 How could I reshape this array from 6214x1 -> 6214x6?我如何从 6214x1 -> 6214x6 重塑这个数组?

The original array contains strings.原始数组包含字符串。 So all we have to do is to split them and convert to floats:所以我们所要做的就是将它们拆分并转换为浮点数:

np.array([i.split() for i in a.flat], dtype=float)   # a is the original array

在此处输入图像描述

hope you get the answer from this working希望你能从这个工作中得到答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM