I have a df:
colA colB
0 'abcde' 4
1 'abcde' 2
2 'abcde' 1
3 np.nan np.nan
4 'wxyz' 3
5 'wxyz' 2
What I would like is to be able to remove the first X characters from colA based on the value in colB and return the value to a new column C like below.
colA colB colC
0 'abcde' 4 'e'
1 'abcde' 2 'cde'
2 'abcde' 1 'bcde'
3 np.nan np.nan np.nan
4 'wxyz' 3 'z'
5 'wxyz' 2 'yz'
I've tried some .apply lambda's here 1 with .str[x:] but running into trouble saving it back due to null values in other rows.
Any help much appreciated!