Remove "x" number of characters from a string in a pandas dataframe? Remove "x" number of characters from a string in a pandas dataframe? pandas pandas

Remove "x" number of characters from a string in a pandas dataframe?


Using zip with string slice

df.a=[x[y:] for x,y in zip(df.a,df.b)]dfOut[584]:           a  b0  sastring  51   rstring  62      ring  7


You can do it with apply, to apply this row-wise:

df.apply(lambda x: x.a[x.b:],axis=1)0    sastring1     rstring2        ringdtype: object