I hope they are fine, how can I divide this single column into n equal parts as seen in the code
df = pd.DataFrame(np.random.randn(30))
I have done this way
First I have made the division, since there are 30 records, it divides it into 3 parts
n = 3 #chunk row size
list_df = [df[i:i+n] for i in range(0,df.shape[0],n)]
result = pd.concat([list_df[0],
list_df[1].reset_index().drop(columns='index'),
list_df[2].reset_index().drop(columns='index')
], axis=1, ignore_index=True, sort=False)
It works fine for the example, but what if I have to divide into more columns, how can I automate it more quickly? Thanks for the support