debugging the full backend code
In [3]:
%matplotlib inline
%load_ext autoreload
%autoreload 2
import the new haven report card module
In [34]:
import nhrc2
from nhrc2.backend import get_neighborhoods as get_ngbrhd
from nhrc2.backend import read_issues as ri
import pandas as pd
import numpy as np
now determine the root directory for the repo:
In [5]:
nhrc2dir = '/'.join(str(nhrc2.__file__).split('/')[:-1])+'/'
In [ ]:
In [37]:
scf_df_cat = ri.read_categories()
In [38]:
scf_df_cat
Out[38]:
In [39]:
scf_df_cat[scf_df_cat['organization'] == 'City of New Haven']
Out[39]:
read in the issue data from file (to speed things up)
In [7]:
readfile=False
writejson=False
scf_df = ri.get_issues(readfile=readfile, writejson=writejson)
now determine the neighborhoods for each issue using the get_neighborhoods routine:
In [8]:
hoods = get_ngbrhd.get_neighborhoods()
now add the neighborhoods to the DataFrame:
In [9]:
scf_df['neighborhood'] = hoods
There are a few things that it would be nice to calculate. Namely,
In [10]:
scf_df.columns
Out[10]:
In [18]:
scf_df.loc[0:1, 'created_at']
Out[18]:
In [15]:
pd.to_datetime(scf_df.loc[0, 'created_at'])
Out[15]:
In [29]:
scf_df['time_to_acknowledge'] = (pd.to_datetime(scf_df['acknowledged_at']) - pd.to_datetime(scf_df['created_at']))/pd.Timedelta('1d')
In [33]:
scf_df['time_to_close'] = (pd.to_datetime(scf_df['closed_at']) - pd.to_datetime(scf_df['created_at']))/pd.Timedelta('1d')
In [32]:
scf_df.loc[0:1, 'time_to_acknowledge']
Out[32]:
In [35]:
np.median(scf_df['time_to_acknowledge'].values)
Out[35]:
In [36]:
np.median(scf_df['time_to_close'].values)
Out[36]:
In this section I compute the progress made since the previous time period.
In [ ]: