1
I have the following code:
df = pd.DataFrame(repeat_R)
print(df)
The dataframe I have is like this:
0
0 0.583822
1 0.582975
2 0.541191
3 0.526122
4 0.547239
5 0.555875
6 0.556838
7 0.524316
8 0.594906
9 0.559264
10 0.551321
11 0.530168
12 0.566200
13 0.499690
14 0.552580
15 0.523648
16 0.573826
17 0.554709
18 0.566220
19 0.505065
20 0.573585
21 0.586732
22 0.565730
23 0.534764
24 0.593547
25 0.573899
26 0.562164
27 0.529680
28 0.578324
29 0.484839
30 0.552086
31 0.549009
32 0.549631
33 0.499424
34 0.542479
35 0.511983
36 0.558355
37 0.491869
38 0.548544
39 0.485955
I want the new dataframe to have in the first column the first 10 values, in the second the 10 second values, in the third the 10 third values and in the fourth the 10 fourth values. I tried to divide the original dataframe into four dataframes and then join one, but not the right one:
df1 = df.iloc[0:9]
print(df1)
df2 = df.iloc[10:19]
print(df2)
df3 = df.iloc[20:29]
print(df3)
df4=df.iloc[30:39]
print(df4)
result = pd.concat([df1, df2, df3, df4], axis=1, join='inner')
Someone would know how to solve?
Thanks Hartnäckig! It worked perfect, that’s just what I needed!
– Patricia Padula Lopes