Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added lat/long, changed blanks and na to nan #18

Merged
merged 1 commit into from
Jan 25, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions analysis/analysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import pandas as pd
import numpy as np



def mwrd(directory='/Users/thoughtworker/chicago-river-sewage/data/', file='mwrd_rain_measurements.csv'):
data= pd.read_csv(directory+file, na_values='na')
print data.shape[0]
location= list(set(data.ix[0:,3]))

lat=['nan',41.824857, 42.079825, 41.821587, 41.734139, 41.659136, 41.894294, 41.912744, 41.721979, 42.075623, 41.970287, 42.019087, 41.735587]
lng=['nan',-87.655586, -87.821792, -87.773094, -87.782139, -87.612606, -87.625152, -87.723944, -87.548275, -87.685299, -87.701213, -87.716341, -87.682604]

latitude,longitude={},{}
for key, val in zip(location, lat):
latitude[key]=val
for key, val in zip(location,lng):
longitude[key]= val
print len(latitude), len(longitude)

coord=np.zeros(shape=(data.shape[0],2))
ct=0
for loc in data.ix[:,3]:
coord[ct,0]=latitude[loc]
coord[ct,1]=longitude[loc]
ct+=1

data_new=np.hstack((data.ix[:,:],coord))

print data_new.shape
np.savetxt(file, data_new,fmt='%s', delimiter=",")

def clean_water(directory='/Users/thoughtworker/chicago-river-sewage/data/',file='clean-waterway-measurements.csv'):
data=pd.read_csv(directory+file, na_values='na')
np.savetxt(file, data,fmt='%s', delimiter=",")

def cso():
directory='/Users/thoughtworker/chicago-river-sewage/data/'
cso_file='cso_events_timestamped.csv'

cso_data= pd.read_csv(directory+cso_file, na_values='na')
print cso_data.shape


if __name__=="__main__":
mwrd()
#cso()
#clean_water()
Loading