- I'm trying to go through each row in column 'birth'
- Check if the last part of the string separated by "," ends in two characters 2.a. If it does, I will append "US" to it.
So, "Los Angeles, Ca" would be "Los Angeles, Ca, US" And "Bisacquino, Sicily, Italy" would stay the same
I want to process this in a function.
I've tried this but when checking checking the length of birthStr it gives me the length of all the rows
for row in subset.itertuples():
birthStr= subset['birth'].str.rsplit(",", 1).str[-1]
if len(birthStr) ==2:
subset.birth = birthStr + "," + "US"