I have the dataframe:
vid_fn V1 V2 V3
a.avi 1 4 5
b.avi 7 8 1
I want to change duplicate each row 5 times, while changing the first column:
frame_fn V1 V2 V3
a1.jpg 1 4 5
a2.jpg 1 4 5
a3.jpg 1 4 5
a4.jpg 1 4 5
a5.jpg 1 4 5
b1.jpg 7 8 1
b2.jpg 7 8 1
b3.jpg 7 8 1
b4.jpg 7 8 1
b5.jpg 7 8 1
the 5 values are generate by an outer function, so when calling
my_func(a.avi)
I get:
[a1.jpg, a2.jpg, a3.jpg, a4.jpg, a5.jpg]
What is the best way to do so?
You can
map
the functionmy_func
overvid_fn
thenexplode
the dataframe onvid_fn
: