Parse and replace last 2 specific characters from the string if available.
For Eg: 0 = O, 5 = S, 1=I
Input Data:
Col1
AZBYCCCD0
NZBY23HG1
BZYCQ05CO
YODZ225H0
NaN
CS45DRNZQ
Expected Output:
Col1
AZBYCCCDO
NZBY23HGI
BZYCQ05CO
YODZ225HO
NaN
CS45DRNZQ
I have been trying to use :
repl = {'0':'O','1':'I'}
df['Col1'] = df['Col1'].astype(str).str[7:].replace(repl, regex=True)
But the above script doesn't work.
Please Suggest