I've some list which is in weird shape as follows. list is saved in a var res
print(res)
output I got when I print this list
[ identity VGG-Face_cosine img
0 ./clip2/0.png 1.110223e-16 .\clip1\0.png
1 ./clip2/2.png 1.117194e-01 .\clip1\0.png
2 ./clip2/6.png 1.117194e-01 .\clip1\0.png
3 ./clip2/1.png 1.476002e-01 .\clip1\0.png,
identity VGG-Face_cosine img
0 ./clip2/1.png 4.440892e-16 .\clip1\1.png
1 ./clip2/2.png 1.284562e-01 .\clip1\1.png
2 ./clip2/6.png 1.284562e-01 .\clip1\1.png
3 ./clip2/0.png 1.476002e-01 .\clip1\1.png,
identity VGG-Face_cosine img
0 ./clip2/2.png -4.440892e-16 .\clip1\2.png
1 ./clip2/6.png -4.440892e-16 .\clip1\2.png
2 ./clip2/0.png 1.117194e-01 .\clip1\2.png
3 ./clip2/1.png 1.284562e-01 .\clip1\2.png,
identity VGG-Face_cosine img
0 ./clip2/3.PNG 3.330669e-16 .\clip1\3.PNG,
identity VGG-Face_cosine img
0 ./clip2/4.PNG 0.0 .\clip1\4.PNG
1 ./clip2/8.PNG 0.0 .\clip1\4.PNG,
identity VGG-Face_cosine img
0 ./clip2/5.jpg -2.220446e-16 .\clip1\5.jpg ]
I've checked type of output
type(res)
output
list
my aim is to convert this into pandas df
. By reading documentation what I've tried is
import pandas as pd
df_new = pd.DataFrame(res)
output I got
0 identity VGG-Face_cosine img 0 ./clip2/0.png 1.110223e-16 .\clip1\0.png 1 ./clip2/2.png 1.117194e-01 .\clip1\0.png 2 ./clip2/6.png 1.117194e-01 .\clip1\0.png 3 ./clip2/1.png 1.476002e-01 .\clip1\0.png
1 identity VGG-Face_cosine img 0 ./clip2/1.png 4.440892e-16 .\clip1\1.png 1 ./clip2/2.png 1.284562e-01 .\clip1\1.png 2 ./clip2/6.png 1.284562e-01 .\clip1\1.png 3 ./clip2/0.png 1.476002e-01 .\clip1\1.png
2 identity VGG-Face_cosine img 0 ./clip2/2.png -4.440892e-16 .\clip1\2.png 1 ./clip2/6.png -4.440892e-16 .\clip1\2.png 2 ./clip2/0.png 1.117194e-01 .\clip1\2.png 3 ./clip2/1.png 1.284562e-01 .\clip1\2.png
3 identity VGG-Face_cosine img 0 ./clip2/3.PNG 3.330669e-16 .\clip1\3.PNG
4 identity VGG-Face_cosine img 0 ./clip2/4.PNG 0.0 .\clip1\4.PNG 1 ./clip2/8.PNG 0.0 .\clip1\4.PNG
5 identity VGG-Face_cosine img 0 ./clip2/5.jpg -2.220446e-16 .\clip1\5.jpg
6 identity VGG-Face_cosine img 0 ./clip2/2.png -4.440892e-16 .\clip1\6.png 1 ./clip2/6.png
........................................
output I'm expecting
identity VGG-Face_cosine img
0 ./clip2/0.png 1.110223e-16 .\clip1\0.png
1 ./clip2/2.png 1.117194e-01 .\clip1\0.png
2 ./clip2/6.png 1.117194e-01 .\clip1\0.png
3 ./clip2/1.png 1.476002e-01 .\clip1\0.png
identity VGG-Face_cosine img
0 ./clip2/1.png 4.440892e-16 .\clip1\1.png
1 ./clip2/2.png 1.284562e-01 .\clip1\1.png
2 ./clip2/6.png 1.284562e-01 .\clip1\1.png
3 ./clip2/0.png 1.476002e-01 .\clip1\1.png
identity VGG-Face_cosine img
0 ./clip2/2.png -4.440892e-16 .\clip1\2.png
1 ./clip2/6.png -4.440892e-16 .\clip1\2.png
2 ./clip2/0.png 1.117194e-01 .\clip1\2.png
3 ./clip2/1.png 1.284562e-01 .\clip1\2.png
identity VGG-Face_cosine img
0 ./clip2/3.PNG 3.330669e-16 .\clip1\3.PNG
identity VGG-Face_cosine img
0 ./clip2/4.PNG 0.0 .\clip1\4.PNG
1 ./clip2/8.PNG 0.0 .\clip1\4.PNG
identity VGG-Face_cosine img
0 ./clip2/5.jpg -2.220446e-16 .\clip1\5.jpg
Am i missing anything here?.
CodePudding user response:
IIUC use concat
- seems you get list of DataFrames:
df = pd.concat(res)
Difference of your expected ouput is only one header.