917 1st St, Dallas, TX 75001
682 Chestnut St, Boston, MA 02215
669 Spruce St, Los Angeles, CA 90001
669 Spruce St, Los Angeles, CA 90001
so, i'm trying to extract the city and state from the given data...
def get_city_state(address):
asplit = address.split(",")
ssplit = address.split(" ")
city = asplit[1].split()[-1]
state = asplit[2].split()[0]
return city , state
all_data['City'] = all_data['Purchase Address'].apply(lambda x: f"{get_city_state(x)}")
all_data.head()