Want to get involved? We're always looking for ideas and content for Weekly Challenges.
SUBMIT YOUR IDEAThis was a fun one! I initially completed this challenge without using RegEx. However, upon seeing that it was used in many solutions posted here, I learned how to use it and completed the challenge again.
Here are my two solutions:
i tad harder than "beginner" level... i went with Python usaddress library and then CASS/regex Tools for the pure Alteryx approach. Even the python method took me throughout yesterday to track down how to manipulate the output.
#################################
from ayx import Alteryx
import usaddress as usadd
import pandas as pd
add = Alteryx.read('#1')
add['parsed'] = add['Address Text'].apply(lambda x:
usadd.tag(x))
def par_address(text,variable):
try:
return text[0][variable]
except KeyError as e:
return None
add['AddressNumber'] = add['parsed'].apply(lambda x:
par_address(x,"AddressNumber"))
add['StreetNamePreDirectional'] = add['parsed'].apply(lambda x:
par_address(x,"StreetNamePreDirectional"))
add['StreetName'] = add['parsed'].apply(lambda x:
par_address(x,"StreetName"))
add['StreetNamePostType'] = add['parsed'].apply(lambda x:
par_address(x,"StreetNamePostType"))
add['OccupancyType'] = add['parsed'].apply(lambda x:
par_address(x,"OccupancyType"))
add['OccupancyIdentifier'] = add['parsed'].apply(lambda x:
par_address(x,"OccupancyIdentifier"))
add['PlaceName'] = add['parsed'].apply(lambda x:
par_address(x,"PlaceName"))
add['StateName'] = add['parsed'].apply(lambda x:
par_address(x,"StateName"))
add['ZipCode'] = add['parsed'].apply(lambda x:
par_address(x,"ZipCode"))
add = add.drop(columns=['parsed'])
Alteryx.write(add,3)
#SnakingMyWayThruChallenges
Here is my solution.
Here is my solution! In browsing through others', looks similar to CKP's recent one
My solution would not work if there were hundreds of records but there were only 8 displayed, so I basically kept adding formulas to get the data to look how it looks in the output goal. I'm still a beginner and even though this challenge says "beginner", I saw the posted solutions and became overwhelmed so I did it my own way. Again, not the most practical way at all, but it gave me some good practice with formulas.
I'm really getting into RegEx. Or maybe I'm becoming a masochist...
In attach my solution