Issue
I have dataframe:
col1
1a
2b
3d
4a
5a
6f
7a
8a
9e
How to get that dataframe:
col1 col2 col3
1a 2b 3d
4a 5a 6f
7a 8a 9e
Solution
Use numpy reshape:
pd.DataFrame(np.reshape(df.col1.to_numpy(), (-1, 3)),
columns = ['col1', 'col2', 'col3'])
col1 col2 col3
0 1a 2b 3d
1 4a 5a 6f
2 7a 8a 9e
Answered By - sammywemmy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.