diff --git a/pandas_usaddress/__init__.py b/pandas_usaddress/__init__.py index 14bd25c..01bf42a 100644 --- a/pandas_usaddress/__init__.py +++ b/pandas_usaddress/__init__.py @@ -63,6 +63,12 @@ def usaddress_field_creation(x,i): except: None +def usaddress_address_type(x): + try: + return x[1] + except: + None + def trim(x): x = str(x) x = x.split() @@ -99,8 +105,9 @@ def tag(dfa, address_columns, granularity='full', standardize=False): for i in usaddress_fields: df[i] = df['odictaddress'].apply(lambda x: usaddress_field_creation(x,i)) - + df['address_type'] = df['odictaddress'].apply(usaddress_address_type) + df = df.drop(columns='odictaddress') @@ -269,4 +276,4 @@ def tag(dfa, address_columns, granularity='full', standardize=False): df = df.replace({'None': np.nan, 'none': np.nan, 'nan': np.nan, 'NaN': np.nan, None: np.nan, '': np.nan}).copy() - return df \ No newline at end of file + return df