Home > Back-end >  numpy create column after blank space
numpy create column after blank space

Time:10-12

I have numpy array of size (6214,1), which looks like this:

image

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 ?

CodePudding user response:

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

CodePudding user response:

enter image description here

hope you get the answer from this working

  • Related