Reputation: 581
I have a dataframe as seen below and am trying to place the existing information to other columns.
A B C
aa bb cc dd ee ff gg hh ii .....
and I am trying to get the other columns of information to go under columns A-C.
A B C
aa bb cc
dd ee ff
gg hh ii
Any idea of how to do so? Thanks for your help!
Upvotes: 0
Views: 17
Reputation: 150785
If the number of columns is divisible by 3, you can use reshape
:
pd.DataFrame(df.values.reshape(-1,3), columns=['a','b','c'])
Upvotes: 1