I am trying to change the strings in a Pandas Series by a condition. If the string name is say 'A', it should be 'AA'. The code snippet below works but it is very un elegant and inefficient. I am passing a Pandas series as an argument as I said. Is there any other way to accomplish this?
def conditions(x):
if x == 'A':
return "AA"
elif x == 'B':
return "BB"
elif x == 'C':
return "CC"
elif x == 'D':
return "DD"
elif x == 'E':
return "EE"
elif x == 'F':
return "FF"
elif x == 'G':
return "GG"
elif x == 'H':
return "HH"
elif x == 'I':
return "I"
elif x == 'J':
return "JJ"
elif x == 'K':
return "KK"
elif x == 'L':
return 'LL'
func = np.vectorize(conditions)
test = func(rfqs["client"])