I want to extra the first portion of column (B) based on the value of another column (A) minus 1 to get an output. Eg, if column A is 4 than I want the first 3 characters of column B.
Any suggestions? Greatly appreciated!
+---+---------------+------+
| A | B | Out |
+---+---------------+------+
| 4 | CTAAT | CTA |
| 3 | GKAEI | GK |
+---+---------------+------+
ie first 3 letters of column B in row 1, the fist 2 letters of column B in row 2.
My current approach that isn't working:
df['output']= df.B.str[0:(df[A]-1)]