I am trying to slice a string in a column based on the values in two other columns (ideally method-chained):
df = pd.DataFrame({'a':["abcde", "abcdefg"], 'start':[0,3], 'end':[3,5]})
df.assign(c = lambda x: x.a.str.slice(x.start,x.end))
returns:
a start end c
0 abcde 0 3 NaN
1 abcdefg 3 5 NaN
expected:
a start end c
0 abcde 0 3 abc
1 abcdefg 3 5 def