I have a data frame as
Product Photo 1 Photo 2 Photo 3 Photo 4 Price
Shirt a.jpg b.jpg c.jpg d.jpg 100
Pant e.jpg 245
Coat f.jpg g.jpg 433
and the list as
values = [['A,'B','C'],['D','E','F','G'],['H','I','J','K]]
These data frames should be added and should start from index values[2] and the list should increase from the index as per the number of rows in the data frame. The columns should be split too like in the output format. The elements should be looped for every row.
Expected output
values = [['A,'B','C'],['D','E','F','G'],['PHOTO','a.jpg'],['PHOTO','b.jpg'],
['PHOTO','c.jpg'],['PHOTO','d.jpg'],['H','I','J','K],
['A,'B','C'],['D','E','F','G'],
['PHOTO','e.jpg'],['H','I','J','K], ['A,'B','C'],['D','E','F','G'],
['PHOTO','f.jpg',], ['PHOTO','g.jpg'], ['H','I','J','K]
]
Then, I want to convert this list to data frames. What I've tried:
L = [df.loc[:, x].set_axis(range(len(x)), axis=1) for x in values]
df = pd.concat(L).sort_index(kind='mergesort').fillna('').reset_index(drop=True)
df = df.fillna('')
output from this code in the previous case:
A B C
D E F G
H I J K
#the data frame repeats till the number of rows in the previous df.