I'm looking for better ways to replace values inside a column with respect to certain rules.
My table look like this :
data NB
1Y 1Yf
3Y 3Yf
4Y 4Yf
1M 1Mf
3M 3Mf
1Y 1Yf
3Y 3Yf
5Y 4Yf
Here's my code works but im looking for other ways to do it
def test(ls):
n=0
while n<len(ls):
if ls[n]=='1M':
ls[n]=0.083
n=n+1
elif ls[n]=='3M':
ls[n]=0.25
n=n+1
elif ls[n]=='1Y':
ls[n]=1
n=n+1
elif ls[n]=='3Y':
ls[n]=3
n=n+1
elif ls[n]=='4Y':
ls[n]=4
n=n+1
else:
ls[n]='error'
n=n+1
test(df['data'])