def region_df(df):
if (df["Region New"] == "OTHER" and df[['COUNTRY NAME']].notnull().all()):
return df["REGION NEWER"]
elif (df["Region New"] == "OTHER" and (df["national Code"].str[:2] == "4A" or df["national Code"][:1]== "3") ):
return 'NOT REEQUIRED'
else :
return df["Region New"]`
I am having issues in slicing the column information in a function.
If I use df["national Code"].str[:2] == "4A" , I get the results but when I use the same in a function as below. It gives me the error. Can anyone help?
Error: AttributeError: 'str' object has no attribute 'str'
Expecting to get "not required" when the df["national Code"] has 4A or 3 in the beginning