df= "start", "stop", "Seq"
50 121 aaaaaaaaaaaaabbbbbbbbbbbbcccccccccc...dddddd
25 150 aaaaahhhhhhhssssssssssssssccccccccc...dddddd
I need to extract a substring in column "Seq" of the dataframe(df) using str.slice(start=start, stop=stop) using as start and stop values the values in a columns named "start" and "stop" (for each of the rows of the dataframe).
I would like to use a def function or lambda but I get errors
def f(x,y,z):
return z.str.slice(start=x, stop=y)
df.apply(lambda x: f(x["start"],x["stop"],x["Seq"]))
Output: KeyError: ('start', 'occurred at index id')