text_html_output_1.png
import pandas as pd

df = pd.read_csv('../input/cameras.csv')

df.shape

df.columns.values

df.dtypes

df.replace('NaN', -1, inplace=True)
(df['LATITUDE'] == -1).count()

df.dtypes

df.shape

df.columns

df.drop('LOCATION', axis=1, inplace=True)

def find_one(substrs, superstr):
    for substr in substrs:
        if superstr.find(substr) != -1:
            return substr
    return ''
address_values = df['ADDRESS'].values
street_values = []
for name_value in address_values:
    street_values.append(find_one(['N PULASKI', 'W PERSHING', 'S WESTERN', 'W JACKSON', 'W MADISON', 'N HUMBOLDT', 'W AUGUSTA', 'S COTTAGE GROVE', 'S KEDZIE', 'W 71ST', 'W ROOSEVELT', 'W OGDEN', 'W PETERSON', 'W FOSTER', 'N WESTERN', 'W ADDISON', 'E MORGAN DR', 'S PULASKI', 'S ARCHER', 'S STATE', 'E 95TH', 'W FULLERTON', 'W GRAND', 'W 127TH', 'W 111TH', 'N CENTRAL AVE', 'W IRVING PARK', 'N LINCOLN', 'S CENTRAL AVE', 'S VINCENNES', 'W 79TH', 'N ASHLAND', 'N OGDEN', 'W BELMONT AVE', 'N MILWAUKEE AVE', 'N CLYBOURN AVE', 'N RIDGE AVE', 'N BROADWAY', 'W 51ST ST', 'S JEFFERY', 'W HIGGINS', 'W LAWRENCE', 'N NARRAGANSETT AVE', 'W CHICAGO AVE', 'S HALSTED', 'S RACINE AVE', 'W GARFIELD BLVD', 'S INDIANAPOLIS', 'N COLUMBUS DR', 'W 76th ST', 'E 75TH ST', 'W 55TH', 'W MONTROSE', 'E ILLINOIS ST', 'S EWING AVE', 'W SUPERIOR ST', 'E 95TH ST', 'W CERMAK RD', 'N CICERO AVE', 'W DIVISION ST', 'W BRYN MAWR AVE', 'N NORTHWEST HWY', 'E 87TH ST', 'E 63RD ST', 'S MARTIN LUTHER KING', 'S ASHLAND AVE', 'W 83rd ST', 'W 103RD ST', 'W NORTH AVE'], name_value))
one_hot = pd.get_dummies(street_values, 'Title', '_')
df.drop('ADDRESS', axis=1, inplace=True)
df = pd.concat([df, one_hot], axis=1)

df.columns

df.drop('Title_', axis=1, inplace=True)

df.columns