I am very new to python (I generally use R). I have a list of addresses that I need to normalize. I would like to do the following.
- Normalize each address in the list using the scourgify package
- Append the data to my original data.frame.
On github, it is easy to see how to do one address, but how would I do this to a list or vector of addresses?
from scourgify import normalize_address_record
normalize_address_record('123 southwest Main street, Boring, or, 97203')
normalize_address_record({
'address_line_1': '123 southwest Main street',
'address_line_2': 'unit 2,
'city': 'Boring',
'state': 'or',
'postal_code': '97203'
})
expected output
{
'address_line_1': '123 SW MAIN ST',
'address_line_2': 'UNIT 2'
'city': 'BORING',
'state': 'OR',
'postal_code': '97203'
}
Here is some dummy data based on my original dataset
# initialize list of lists
data = [['a', '123 southwest Main street, Boring, or, 97203'], ['b', '4285 balsam la n plymouth mn 55441'], ['c', '632 bloomington ave s minneapolis mn 55417']]
# Create the pandas DataFrame
df = pd.DataFrame(data, columns = ['id', 'address_original'])
I need the output in tabular format appended to my original data.frame. Any help would be greatly appreciated.