Category Archives: Chicago Data

Comcast’s Monetary Influence Over Illinois Political Candidates

I found an interesting dataset on political contributions in the state of Illinois.. The downloadable .zip contains multiple tab delimited database files which contain the relationships between Donations, Committees, and Candidates.

Out of curiosity in seeing Comcast’s political influence in Illinois over time, I parsed the 650,775mb file called Receipts.txt. Below is a bar chart of yearly recorded donation totals from 2000 through 2015-08.

Comcast_DPolitical_Donations_2000-2015-6_2

Not being very politically oriented, I wanted to somehow relate the donations to candidates. But in the form of the available data, it appears Donors make contributions to Committees, and Committees support a Candidate. But I do not know if Candidates and Committees are a One to One relationship at the time of typing this.

Parsing the text file called CmteCandidateLinks.txt, I related the Committee Id with the candidate Id. Parsing the text file called Candidates.txt I relate the Candidate Id to the Candidate name.

Lots of candidate duplicates per donation entry. Majority of Committees represent the same candidate under different ids, while some committees represent multiple candidates. Example here:

donations-2-commit-2-candids

So I decided to distribute each donation amount between a potential multitude of candidates. I did this by dividing each donation by the number of candidates which belong to the committee recipient. From that, I got this list of Comcast’s Top Illinois Candidates.

top_20_illinois_Candidates_Recieve_Donation_from_Comcast

Continue reading

Cook County Employee Healthcare Costs by Department – June 2012

I came across an interesting data set while browsing datacatalog.cookcountyil.gov.  It can be found here.  Judging by the title, it appears to be healthcare costs for the month of June in the year of 2012.  There is no description, or any additional information I could find about it.  The data contains a department code, a number of employees, and a total cost.  It looks like this:

datascreenshot

I was curious, so I took the average cost of employee count (Cost / Emp num), per department.  I correlated the department numbers to labels from an alternative dataset also found on cook county’s data catalog.

My experiment resulted in two bubble charts.

Greater than 40 Employees

AverageEmployeeCostPerDepartment_GreaterThan40Employees

 

Greater than 40 Employees and less than 1,000

AverageEmployeeCostPerDepartment_GreaterThan40EmployeesLessThan1000

And now here’s the second chart processed with Google’s Deep Dream

2

Chicago Cannabis Decriminalization

A look into Chicago Police Department’s incident reports for marijuana related arrests.

ChicagoCannabisArrests_STill

The chart below displays over 15 years of CPD’s Cannabis related arrests for possession of 30 grams or less. The data is from data.cityofchicago.org

ChicagoCannaBisArrests_2001-2015_monthly_lessthan30gms

Here is the ruby code written to accumulate the monthly totals. Additional data filtering was done on the Socrata website prior to exporting the csv data file. Google Charts was used to create the line chart. CartoDB was used to create the still of the torque map.
rubytoparsechicagocannabis

Chicago’s Prostitution Maps

A look into 15 years worth of prostitution through the eyes of the Chicago Police Department. The data is from data.cityofchicago.org. Time range includes years 2001 through 2015. CartoDB was used to create a Density, and Torque Map.

Density map
ChicagoProstitution2001-2015

Geo-temporal map animation, 15 years in 10 seconds.

West Side Chicago Narcotics Enforcement Migrations

In this post I look into Chicago Police Department’s enforcement of two particular narcotics report types: Heroin and Crack Cocaine. I was curious to see yearly migrations of CPD’s activity from 2003 to 2014 in the west side region of Chicago.

heroin and crack molecule

The Data is from City of Chicago Data Portal

Links to youtube video animated heatmaps (some mobile devices don’t support embedded videos on my site):
http://www.youtube.com/watch?v=2qGPhlBGWxQ
http://www.youtube.com/watch?v=uh22pGBLgYo
http://www.youtube.com/watch?v=czoofaWOAps

Monthly

Yearly


Ruby was used to parse the data and convert into JSON.
Google Heatmaps API was used to generate the maps.
Camtasia Studio 8 was used to annotate and export the videos.

Ruby written to create monthly maps

RubyToCreateMonthlyMaps

Chicago, Cook County – Defense Department’s 1033 program charts.

The data was found on github here:
Military Surplus Gear

The charts below cover Chicago, IL, Cook County
gunart

 This chart displays Rifles and Pistols received by year.
riflespistols1033cookcounty

This graph shows most popular equipment items received from 2006 through May 2014.
AllEquipment

 

Ruby code used to parse and format the data.  Google charts was used to display it.
Ruby to Parse all equipment in cook county

 

Chicago Gov-Job Average Salary Bubble Charts.

According to this data : Current Employee Names, Salaries, and Position Titles on City Of Chicago Data Portal https://data.cityofchicago.org/;

The Chicago government employees 32,160 employees, and pays approximately $2,429,980,941.36 in annual salaries.

Google Charts API was used.

CLICK ON Pictures FOR Focus. (temporary courtesy of imgur)

All Employees.

image1

Let’s remove distinct Position-Titles with Less Then 10 Employees, and the position title of Police Officer from the data.

image2

(20 or more), and, (200 or less); employee counts within a position title.

image3

(10 or more), and,( 50 or less); employee counts within a position title.

FINALBIGCHART

C#

int counter = 0;
string line;
Dictionary<string, int> dCount = new Dictionary<string, int>();
Dictionary<string, decimal> dSalTotal = new Dictionary<string, decimal>();
Dictionary<string, LinkedList> dDeps = new Dictionary<string, LinkedList>();
System.IO.StreamReader file =
    new System.IO.StreamReader("C:\\AAAChicagoEmployees\\Current_Employee_Names__Salaries__and_Position_Titles (1).csv");
while ((line = file.ReadLine()) != null)
{
    string[] parts = line.Split(',');
    try
    {
        string name = parts[2];
        name = Regex.Replace(name, "'", "");
        string dep = parts[3];
        decimal sal = decimal.Parse(parts[4].TrimStart('$')   );
        if ( dCount.ContainsKey(name  ) )
        {
            int a = dCount[name];
            a += 1;
            dCount[name] = a;
            decimal b = dSalTotal[name];
            b += sal;
            dSalTotal[name] = b;
            LinkedList c = dDeps[name];
            c.AddLast(dep);
            dDeps[name] = c;
        }
        else
        {
            dCount.Add(name, 1);
            dSalTotal.Add(name, sal);
            LinkedList newDepList = new LinkedList();
            newDepList.AddLast(dep);
            dDeps.Add(name, newDepList);
        }
    }
    catch (Exception x)
    {
        //header line
    }
    counter++;
}
file.Close();
Dictionary<string, decimal> dAveOrder = new Dictionary<string, decimal>();
foreach (KeyValuePair<string, int> item in dCount.OrderBy(key => key.Value))
{
    if (item.Value >= 10 && item.Value <= 50)
    {
        decimal aveSal = dSalTotal[item.Key] / item.Value;
        dAveOrder.Add(item.Key, aveSal);
    }
}
string json = "";
foreach (KeyValuePair<string, decimal> item in dAveOrder.OrderBy(key => key.Value))
{
    Hashtable frequencyHash = new Hashtable();
    LinkedList uniqueList = new LinkedList();
    foreach (var element in dDeps[item.Key])
    {
        if (uniqueList.Contains(element))
        {
            int elementCount = int.Parse(frequencyHash[element].ToString());
            elementCount++;
            frequencyHash[element] = elementCount;
        }
        else
        {
            uniqueList.AddLast(element);
            frequencyHash.Add(element, 1);
        }
    }
    int max = 0;
    string sMaxDep = "";
    foreach (string element in frequencyHash.Keys)
    {
        int iDep = int.Parse(frequencyHash[element].ToString());
        if (iDep > max)
        {
            max = iDep;
            sMaxDep = element;
        }
    }
    if (item.Key == "POLICE OFFICER")
    { }
    else
    {
        json += "[ '" + item.Key + "', " + dCount[item.Key] + "  , " + item.Value + " ,'" + Regex.Replace(sMaxDep, "'", "") + "' , " + item.Value + " ],\r\n";
    }
}
System.IO.StreamWriter fileWrite = new System.IO.StreamWriter("c:\\AAAChicagoEmployees\\data.txt");
fileWrite.WriteLine(json);
fileWrite.Close();

Chicago West Side Narcotics Arrest Heat Maps 1/1/2013 – 5/8/2014

A look into the West Side of Chicago’s Narcotics related Arrests.

westSide Chicago

The data is from City of Chicago Data Portal. Time Range used from 1-1-13 through 5-8-14. Data was exported and saved as CSV. Ruby code was written to parse out and format the coordinates. Google Heatmaps Javascript API v3 was used to generate the heatmaps.

Heroin
POSS: HEROIN(WHITE), MANU/DELIVER: HEROIN (WHITE), POSS: HEROIN(BRN/TAN), POSS: HEROIN(BLACK TAR), MANU/DELIVER: HEROIN(BRN/TAN), MANU/DELIVER:HEROIN(BLACK TAR)
heroin_crop

Cocaine
POSS: COCAINE, MANU/DELIVER:COCAINE
cocaine_crop

Crack
MANU/DELIVER:CRACK, POSS: CRACK
crack_crop

PCP
POSS: PCP, MANU/DELIVER:PCP
pcp_crop

Marijuana
POSSESSION: SYNTHETIC MARIJUANA, MANU/POSS. W/INTENT TO DELIVER: SYNTHETIC MARIJUANA, POSS: CANNABIS 30GMS OR LESS, MANU/DEL:CANNABIS OVER 10 GMS, POSS: CANNABIS MORE THAN 30GMS, MANU/DEL:CANNABIS 10GM OR LESS, DELIVER CANNABIS TO PERSON <18, CANNABIS PLANT, ATTEMPT POSSESSION CANNABIS
marijuana_crop

Hallucinogen
POSS: HALLUCINOGENS, MANU/DELIVER: HALLUCINOGEN
hallucinagen_crop