I am trying to create a normalized pandas dataframe with addresses and the parsed addresses using 'usaddress' package in python. I would like to be able to store the results from the parsed output in a dataframe.
The output of usaddress.parse looks like below.
usaddress.parse('Robie House, 5757 South Woodlawn Avenue, Chicago, IL 60637')
[('Robie', 'BuildingName'),
('House,', 'BuildingName'),
('5757', 'AddressNumber'),
('South', 'StreetNamePreDirectional'),
('Woodlawn', 'StreetName'),
('Avenue,', 'StreetNamePostType'),
('Chicago,', 'PlaceName'),
('IL', 'StateName'),
('60637', 'ZipCode')]
I have my address fields in the data dataframe. using above example i am trying to add buildingname, addressnumber etc as column names and the corresponding values as values but no luck.
add = []
for ind in data.index:
add1 = usaddress.Parse(data['address'][ind])
add.append(add1)
res = pd.DataFrame(add)
In using the above code the res dataframe is not the way i intended the output to be. The intended output is