I’m getting crazy with that. I don’t know why is not working well.
My loop is the following:
for f in tqdm.tqdm(frames[::10]): col.set_state_from_frame(f) vertices = generate_dataframe(col) print(f) print(vertices) v_df.append(vertices) v_df = pd.concat(v_df,keys=frames[::10])
In the first print I obtain:
0 x y coordination charge dx dy 0 -28.384776 -56.769553 3 -1 1.0 -2.0 1 1107.006276 1021.851947 3 -1 -1.0 -2.0 2 1050.236724 1050.236724 2 0 -1.0 1.0 3 965.082395 709.619408 3 -3 0.0 1.0 4 823.158513 1021.851947 3 3 -1.0 0.0 ... ... ... ... ... ... ... 1232 1107.006276 709.619408 2 0 -1.0 1.0 1233 652.849855 -85.154329 2 0 1.0 1.0 1234 -28.384776 936.697618 2 -2 1.0 1.0 1235 -28.384776 823.158513 2 2 -1.0 -1.0 1236 -28.384776 766.388960 2 0 -1.0 -1.0 [1237 rows x 6 columns] 10 x y coordination charge dx dy 0 -28.384776 -56.769553 3 -1 1.0 -2.0 1 1107.006276 1021.851947 3 -1 -1.0 -2.0 2 1050.236724 1050.236724 2 0 -1.0 1.0 3 965.082395 709.619408 3 -3 0.0 1.0 4 823.158513 1021.851947 3 3 -1.0 0.0 ... ... ... ... ... ... ... 1232 1107.006276 709.619408 2 0 -1.0 1.0 1233 652.849855 -85.154329 2 0 1.0 1.0 1234 -28.384776 936.697618 2 -2 1.0 1.0 1235 -28.384776 823.158513 2 2 -1.0 -1.0 1236 -28.384776 766.388960 2 0 -1.0 -1.0 [1237 rows x 6 columns] 20 x y coordination charge dx dy 0 -28.384776 -56.769553 3 -1 1.0 -2.0 1 1107.006276 1021.851947 3 -1 -1.0 -2.0 2 1050.236724 1050.236724 2 0 -1.0 1.0 3 965.082395 709.619408 3 -3 0.0 1.0 4 823.158513 1021.851947 3 3 -1.0 0.0 ... ... ... ... ... ... ... 1232 1107.006276 709.619408 2 0 -1.0 1.0 1233 652.849855 -85.154329 2 0 1.0 1.0 1234 -28.384776 936.697618 2 0 -1.0 1.0 1235 -28.384776 823.158513 2 2 -1.0 -1.0 1236 -28.384776 766.388960 2 0 -1.0 -1.0 [1237 rows x 6 columns] 30 x y coordination charge dx dy 0 -28.384776 -56.769553 3 -1 1.0 -2.0 1 1107.006276 1021.851947 3 -1 -1.0 -2.0 2 1050.236724 1050.236724 2 0 -1.0 1.0 3 965.082395 709.619408 3 -1 2.0 1.0 4 823.158513 1021.851947 3 3 -1.0 0.0 ... ... ... ... ... ... ... 1232 1107.006276 709.619408 2 0 -1.0 1.0 1233 652.849855 -85.154329 2 0 1.0 1.0 1234 -28.384776 936.697618 2 0 -1.0 1.0 1235 -28.384776 823.158513 2 0 -1.0 1.0 1236 -28.384776 766.388960 2 0 -1.0 -1.0
But when I show the following dataframe value:
v_df.loc[0]
I obtain:
x y coordination charge dx dy 0 -28.384776 -56.769553 3 -1 1.0 -2.0 1 1107.006276 1021.851947 3 -1 -1.0 -2.0 2 1050.236724 1050.236724 2 0 -1.0 1.0 3 965.082395 709.619408 3 -1 2.0 1.0 4 823.158513 1021.851947 3 3 -1.0 0.0 ... ... ... ... ... ... ... 1232 1107.006276 709.619408 2 0 -1.0 1.0 1233 652.849855 -85.154329 2 0 1.0 1.0 1234 -28.384776 936.697618 2 0 -1.0 1.0 1235 -28.384776 823.158513 2 0 -1.0 1.0 1236 -28.384776 766.388960 2 0 -1.0 -1.0 [1237 rows x 6 columns]
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.