I’m getting crazy with that. I don’t know why is not working well.
My loop is the following:
JavaScript
x
11
11
1
for f in tqdm.tqdm(frames[::10]):
2
3
col.set_state_from_frame(f)
4
5
vertices = generate_dataframe(col)
6
print(f)
7
print(vertices)
8
v_df.append(vertices)
9
10
v_df = pd.concat(v_df,keys=frames[::10])
11
In the first print I obtain:
JavaScript
1
59
59
1
0
2
x y coordination charge dx dy
3
0 -28.384776 -56.769553 3 -1 1.0 -2.0
4
1 1107.006276 1021.851947 3 -1 -1.0 -2.0
5
2 1050.236724 1050.236724 2 0 -1.0 1.0
6
3 965.082395 709.619408 3 -3 0.0 1.0
7
4 823.158513 1021.851947 3 3 -1.0 0.0
8
9
1232 1107.006276 709.619408 2 0 -1.0 1.0
10
1233 652.849855 -85.154329 2 0 1.0 1.0
11
1234 -28.384776 936.697618 2 -2 1.0 1.0
12
1235 -28.384776 823.158513 2 2 -1.0 -1.0
13
1236 -28.384776 766.388960 2 0 -1.0 -1.0
14
15
[1237 rows x 6 columns]
16
10
17
x y coordination charge dx dy
18
0 -28.384776 -56.769553 3 -1 1.0 -2.0
19
1 1107.006276 1021.851947 3 -1 -1.0 -2.0
20
2 1050.236724 1050.236724 2 0 -1.0 1.0
21
3 965.082395 709.619408 3 -3 0.0 1.0
22
4 823.158513 1021.851947 3 3 -1.0 0.0
23
24
1232 1107.006276 709.619408 2 0 -1.0 1.0
25
1233 652.849855 -85.154329 2 0 1.0 1.0
26
1234 -28.384776 936.697618 2 -2 1.0 1.0
27
1235 -28.384776 823.158513 2 2 -1.0 -1.0
28
1236 -28.384776 766.388960 2 0 -1.0 -1.0
29
30
[1237 rows x 6 columns]
31
20
32
x y coordination charge dx dy
33
0 -28.384776 -56.769553 3 -1 1.0 -2.0
34
1 1107.006276 1021.851947 3 -1 -1.0 -2.0
35
2 1050.236724 1050.236724 2 0 -1.0 1.0
36
3 965.082395 709.619408 3 -3 0.0 1.0
37
4 823.158513 1021.851947 3 3 -1.0 0.0
38
39
1232 1107.006276 709.619408 2 0 -1.0 1.0
40
1233 652.849855 -85.154329 2 0 1.0 1.0
41
1234 -28.384776 936.697618 2 0 -1.0 1.0
42
1235 -28.384776 823.158513 2 2 -1.0 -1.0
43
1236 -28.384776 766.388960 2 0 -1.0 -1.0
44
45
[1237 rows x 6 columns]
46
30
47
x y coordination charge dx dy
48
0 -28.384776 -56.769553 3 -1 1.0 -2.0
49
1 1107.006276 1021.851947 3 -1 -1.0 -2.0
50
2 1050.236724 1050.236724 2 0 -1.0 1.0
51
3 965.082395 709.619408 3 -1 2.0 1.0
52
4 823.158513 1021.851947 3 3 -1.0 0.0
53
54
1232 1107.006276 709.619408 2 0 -1.0 1.0
55
1233 652.849855 -85.154329 2 0 1.0 1.0
56
1234 -28.384776 936.697618 2 0 -1.0 1.0
57
1235 -28.384776 823.158513 2 0 -1.0 1.0
58
1236 -28.384776 766.388960 2 0 -1.0 -1.0
59
But when I show the following dataframe value:
JavaScript
1
2
1
v_df.loc[0]
2
I obtain:
JavaScript
1
16
16
1
x y coordination charge dx dy
2
0 -28.384776 -56.769553 3 -1 1.0 -2.0
3
1 1107.006276 1021.851947 3 -1 -1.0 -2.0
4
2 1050.236724 1050.236724 2 0 -1.0 1.0
5
3 965.082395 709.619408 3 -1 2.0 1.0
6
4 823.158513 1021.851947 3 3 -1.0 0.0
7
8
1232 1107.006276 709.619408 2 0 -1.0 1.0
9
1233 652.849855 -85.154329 2 0 1.0 1.0
10
1234 -28.384776 936.697618 2 0 -1.0 1.0
11
1235 -28.384776 823.158513 2 0 -1.0 1.0
12
1236 -28.384776 766.388960 2 0 -1.0 -1.0
13
14
[1237 rows x 6 columns]
15
16
So it seems that is only concatenating the last value.
PD: See charge column in order to see differences between dataframes.
Thank you so much!
Advertisement
Answer
You are using v_df.loc[0]
so it only shows the df with key 0. I think if you print v_df
it will show all of them.