'How can I automate the sequence of dataframe?
My dataframe:
*Ca *O *Ca Ca Hy
0 1 2 3 4 5
1 1
2 1 5
3 1 6 7 8
4 5
5 6
6 6
7 6
8 9
9 9 12
10 9 9 10 11
Desired dataframe will look like:
*Ca *O *Ca Ca Hy
0 1 2 3 4 5
1 1
2 1 5
3 1 6 7 8
4 5
5 6
6 6
7 6
8 9
9 9 12
10 9 9 10 11
11 10 12 13 14 15
12 10 15
13 10 16 17 18
14 10
15 15
16 16
17 16
18 16
.........
That equivalent to:
Ca[i] = a and Ca[i+10] = a+10 but Ca[i+9] =! a+9 We can say that i => 10
I want to get the sequence every 10 rows in a range of 250.
Hopefully, it is clear.
Solution 1:[1]
IIUC,
pd.concat([df, df+10], ignore_index=True)
Or perhaps:
pd.concat([df+i for i in range(0, 250, 10)], ignore_index=True).head(40)
Well looky there, @piRSquared sighting.....
pd.concat(map(df.add, range(0, 250, 10)), ignore_index=True)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
