Created
December 15, 2015 13:45
-
-
Save Akramz/42499a318baf65b11df9 to your computer and use it in GitHub Desktop.
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 numpy as np | |
| import matplotlib.pyplot as plt | |
| from sys import exit | |
| data = pd.read_csv('../data/locations/0.csv', sep = ',') | |
| xyData = data[['X', 'Y', 'Category']] | |
| allList = [ | |
| 'ARSON', | |
| 'ASSAULT', | |
| 'BAD CHECKS', | |
| 'BRIBERY', | |
| 'BURGLARY', | |
| 'DISORDERLY CONDUCT', | |
| 'DRIVING UNDER THE INFLUENCE', | |
| 'DRUG/NARCOTIC', | |
| 'DRUNKENNESS', | |
| 'EMBEZZLEMENT', | |
| 'EXTORTION', | |
| 'FAMILY OFFENSES', | |
| 'FORGERY/COUNTERFEITING', | |
| 'FRAUD', | |
| 'GAMBLING', | |
| 'KIDNAPPING', | |
| 'LARCENY/THEFT', | |
| 'LIQUOR LAWS', | |
| 'LOITERING', | |
| 'MISSING PERSON', | |
| 'NON-CRIMINAL', | |
| 'OTHER OFFENSES', | |
| 'PORNOGRAPHY/OBSCENE MAT', | |
| 'PROSTITUTION', | |
| 'RECOVERED VEHICLE', | |
| 'ROBBERY', | |
| 'RUNAWAY', | |
| 'SECONDARY CODES', | |
| 'SEX OFFENSES FORCIBLE', | |
| 'SEX OFFENSES NON FORCIBLE', | |
| 'STOLEN PROPERTY', | |
| 'SUICIDE', | |
| 'SUSPICIOUS OCC', | |
| 'TREA', | |
| 'TRESPASS', | |
| 'VANDALISM', | |
| 'VEHICLE THEFT', | |
| 'WARRANTS', | |
| 'WEAPON LAWS' | |
| ] | |
| for l in allList: | |
| topFive = [] | |
| topFive.append(l) | |
| justTop = xyData.loc[xyData['Category'].isin(topFive)] | |
| groups = justTop.groupby('Category') | |
| # Plot | |
| fig, ax = plt.subplots() | |
| ax.set_xlim([-122.5247, -122.3366]) | |
| ax.set_ylim([37.699, 37.8299]) | |
| for name, group in groups: | |
| ax.plot(group.X, group.Y, marker='.', linestyle='', label=name) | |
| ax.legend() | |
| plt.show() | |
| exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment