This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def addr_cleaner(addr): | |
'''Split up an address based on typical address markers, | |
because words after the marker tend to mess up geocoding. | |
addr = '1509 DENTONA PL NEW SFR LOT 3 PLAN B3' | |
returns - > '1509 DENTONA PL ' | |
''' | |
address_words = [' AV ', ' DR ', ' PL ', ' ST ', ' WY ', ' RD ', ' LN ',' CT ',' CL ', ' BL ', ' SQ '] | |
# print(addr) | |
for ad in address_words: | |
new_addr = addr.split(ad) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import glob | |
#Combine multiple csv's into one df | |
allFiles = glob.glob('.' + "/gps_*.csv") | |
frame = pd.DataFrame() | |
frames = [] | |
for file_ in allFiles: | |
df = pd.read_csv(file_, header=0) | |
frames.append(df) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List unique values in a DataFrame column | |
pd.unique(df.column_name.ravel()) | |
# Convert Series datatype to numeric, getting rid of any non-numeric values | |
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True) | |
# Grab DataFrame rows where column has certain values | |
valuelist = ['value1', 'value2', 'value3'] | |
df = df[df.column.isin(valuelist)] |