I have a dataframe with large numbers of columns. What I really want is to create/split the dataframe. For example:
generating TOY data:
df = pd.DataFrame(np.arange(10),columns = ['x'])
df['y'] = np.arange(30,40,1)
df['1'] = np.random.rand(10)
df['2'] = np.random.rand(10)
df['3'] = np.random.rand(10)
df['4'] = np.random.rand(10)
df['5'] = np.random.rand(10)
df =
x y 1 2 3 4 5
0 0 30 0.047787 0.435396 0.926836 0.314469 0.477411
1 1 31 0.083536 0.258120 0.682284 0.025050 0.713777
2 2 32 0.201041 0.872864 0.050977 0.580314 0.185589
3 3 33 0.105833 0.974538 0.559265 0.128242 0.217965
4 4 34 0.146551 0.662001 0.936995 0.050702 0.249724
5 5 35 0.098615 0.854952 0.649501 0.509777 0.726458
6 6 36 0.387889 0.040331 0.902277 0.051822 0.354042
7 7 37 0.321591 0.823724 0.052266 0.081491 0.187576
8 8 38 0.983665 0.152271 0.530755 0.384810 0.844386
9 9 39 0.649185 0.776682 0.239589 0.654547 0.581337
What I really want is to split dataframe in such a way like as shown below:
df1 =
x y 1
0 0 30 0.047787
1 1 31 0.083536
2 2 32 0.201041
3 3 33 0.105833
4 4 34 0.146551
5 5 35 0.098615
6 6 36 0.387889
7 7 37 0.321591
8 8 38 0.983665
9 9 39 0.649185
df2 =
x y 2
0 0 30 0.435396
1 1 31 0.25812
2 2 32 0.872864
3 3 33 0.974538
4 4 34 0.662001
5 5 35 0.854952
6 6 36 0.040331
7 7 37 0.823724
8 8 38 0.152271
9 9 39 0.776682
And so on. Since I have large number of columns, so it is very difficult to do it one by one. Is there any simpler way to do that?
Thank you in advance.

