Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bda4f5d
Added proposal and edited readme
Feb 26, 2016
b111b64
Changed heading size in README
Feb 26, 2016
a1ba033
added immigration graph by country and nature
skchandra Mar 3, 2016
986ef64
added html with graph
skchandra Mar 3, 2016
72ff82a
made world map with immigrant data
skchandra Mar 3, 2016
9d6d811
Have mid-project checkin deliverables
Mar 3, 2016
03ae730
Added immigration to counties and ran ipynb
skchandra Mar 4, 2016
d4287aa
cleaned up data and added iteration 1 visuals
Mar 4, 2016
7b35657
Merge branch 'master' of github.com:skchandra/DataScience16CTW
Mar 4, 2016
f1ff6ed
Added breakdown of crime committers by origin plot
Mar 4, 2016
4748b0c
restructuring directories
Mar 5, 2016
2d30021
updated filepaths
skchandra Mar 5, 2016
3b630c5
Started working on counties
skchandra Mar 5, 2016
26bd7f2
Merge branch 'master' of https://github.com/skchandra/DataScience16CTW
skchandra Mar 5, 2016
49ee0bb
Added map selection by country name
Mar 5, 2016
9d8b7bd
Added region to country mapping data and have interactivity between b…
Mar 6, 2016
437ce77
Merge branch 'master' of github.com:skchandra/DataScience16CTW
Mar 6, 2016
dd3301d
Added accurate interactively between regions and bars
Mar 6, 2016
3fe7fae
cleaned up interaction between map and bar graph
Mar 6, 2016
bb04cbb
added second bar chart
Mar 8, 2016
1f8b377
started grouped bar graph
Mar 8, 2016
b37016d
Started modularizing the code
Mar 9, 2016
9b987c7
pushed new work
skchandra Mar 11, 2016
57c8d5f
Added data visualizations in d3! Includes grouped bar charts and mirr…
Mar 11, 2016
4d20322
Merge branch 'master' of github.com:skchandra/DataScience16CTW
Mar 11, 2016
915a865
Removed unnecessary files
Mar 11, 2016
e90306d
commented notebooks
skchandra Mar 11, 2016
f72d971
Merge branch 'master' of https://github.com/skchandra/DataScience16CTW
skchandra Mar 11, 2016
992c962
Added adjustment to README and final reflection
Mar 12, 2016
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pyc
.ipynb_checkpoints*
*.ods
4,140 changes: 4,140 additions & 0 deletions .ipynb_checkpoints/immigration_plots-checkpoint.ipynb

Large diffs are not rendered by default.

320 changes: 320 additions & 0 deletions Bokeh Tutorial.ipynb

Large diffs are not rendered by default.

1,589 changes: 1,589 additions & 0 deletions County_Data.ipynb

Large diffs are not rendered by default.

929 changes: 929 additions & 0 deletions Economy_employment.ipynb

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# DataScience16CTW
This is the base repo for the "Change the World" project for Data Science at Olin College, Spring 2016.
# Sexual Assault and Immigration
## Misinterpreted Data and Lies About Immigrants in Sweden

In an exploration of data visualization and data analysis, we hope to elucidate the meaning of the data behind the recent relation behind sexual assault and immigration in Sweden. For the article written around the data gathered in this repository, [click here!](http://skchandra.github.io/DataScience16CTW/)
101 changes: 101 additions & 0 deletions committed_against.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
committedAgainstGroupedBar = function() {
var margin = {top: 20, right: 20, bottom: 30, left: 300},
width = 850 - margin.left - margin.right,
height = 900 - margin.top - margin.bottom;

var x = d3.scale.linear()
.range([0, width]);

var y0 = d3.scale.ordinal()
.rangeRoundBands([height, 0], .1);

var y1 = d3.scale.ordinal();

var color = d3.scale.ordinal()
.range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]);

var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");

var yAxis = d3.svg.axis()
.scale(y0)
.orient("left");
//.tickFormat(d3.format(".2s"));

var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");

var psv = d3.dsv("|", "text/plain");

queue()
.defer(psv, "https://raw.githubusercontent.com/skchandra/DataScience16CTW/master/data/crime_on_distribution_by_origin.txt")
.await(ready);

function ready(error, data) {
if (error) throw error;

var ageNames = d3.keys(data[0]).filter(function(key) { return key !== "type of crime"; });

data.forEach(function(d) {
d.crimes = ageNames.map(function(name) { return {name: name, value: +d[name]}; });
});

y0.domain(data.map(function(d) { return d["type of crime"]; }));
y1.domain(ageNames).rangeRoundBands([0, y0.rangeBand()]);
x.domain([0, d3.max(data, function(d) { return d3.max(d.crimes, function(d) { return d.value; }); })]);

svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);

svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("Population");

var state = svg.selectAll(".state")
.data(data)
.enter().append("g")
.attr("class", "state")
.attr("transform", function(d) { return "translate(0," + y0(d["type of crime"]) + ")"; });

state.selectAll("rect")
.data(function(d) { return d.crimes; })
.enter().append("rect")
.attr("height", y1.rangeBand())
.attr("y", function(d) { return y1(d.name); })
.attr("x", 0)
//.attr("x", function(d) { return x(d.value); })
.attr("width", function(d) { return x(d.value); })
.style("fill", function(d) { return color(d.name); });

var legend = svg.selectAll(".legend")
.data(ageNames.slice().reverse())
.enter().append("g")
.attr("class", "legend")
.attr("transform", function(d, i) { return "translate(0," + i * 20 + ")"; });

legend.append("rect")
.attr("x", width - 18)
.attr("width", 18)
.attr("height", 18)
.style("fill", color);

legend.append("text")
.attr("x", width - 24)
.attr("y", 9)
.attr("dy", ".35em")
.style("text-anchor", "end")
.text(function(d) { return d; });
}
}
100 changes: 100 additions & 0 deletions committed_by.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
committedByGroupedBar = function() {
var margin = {top: 20, right: 20, bottom: 30, left: 40},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;

var x0 = d3.scale.ordinal()
.rangeRoundBands([0, width], .1);

var x1 = d3.scale.ordinal();

var y = d3.scale.linear()
.range([height, 0]);

var color = d3.scale.ordinal()
.range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]);

var xAxis = d3.svg.axis()
.scale(x0)
.orient("bottom");

var yAxis = d3.svg.axis()
.scale(y)
.orient("left")
.tickFormat(d3.format(".2s"));

var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");

var psv = d3.dsv("|", "text/plain");

queue()
.defer(psv, "https://raw.githubusercontent.com/skchandra/DataScience16CTW/master/data/crime_distribution_by_origin.txt")
.await(ready);

function ready(error, data) {
if (error) throw error;

var ageNames = d3.keys(data[0]).filter(function(key) { return key !== "type of crime"; });

data.forEach(function(d) {
d.crimes = ageNames.map(function(name) { return {name: name, value: +d[name]}; });
});

x0.domain(data.map(function(d) { return d["type of crime"]; }));
x1.domain(ageNames).rangeRoundBands([0, x0.rangeBand()]);
y.domain([0, d3.max(data, function(d) { return d3.max(d.crimes, function(d) { return d.value; }); })]);

svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);

svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("Population");

var state = svg.selectAll(".state")
.data(data)
.enter().append("g")
.attr("class", "state")
.attr("transform", function(d) { return "translate(" + x0(d["type of crime"]) + ",0)"; });

state.selectAll("rect")
.data(function(d) { return d.crimes; })
.enter().append("rect")
.attr("width", x1.rangeBand())
.attr("x", function(d) { return x1(d.name); })
.attr("y", function(d) { return y(d.value); })
.attr("height", function(d) { return height - y(d.value); })
.style("fill", function(d) { return color(d.name); });

var legend = svg.selectAll(".legend")
.data(ageNames.slice().reverse())
.enter().append("g")
.attr("class", "legend")
.attr("transform", function(d, i) { return "translate(0," + i * 20 + ")"; });

legend.append("rect")
.attr("x", width - 18)
.attr("width", 18)
.attr("height", 18)
.style("fill", color);

legend.append("text")
.attr("x", width - 24)
.attr("y", 9)
.attr("dy", ".35em")
.style("text-anchor", "end")
.text(function(d) { return d; });
}
}
606 changes: 606 additions & 0 deletions crime_representation.ipynb

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions data/2005_immigration_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
Citizenship Code 2005_refugees 2005_fam_reun 2005_labour 2005_students 2005_adopted

EUROPE of which 1648 8366 2085 752 86
Bulgaria BGR -

Former Yugoslavia there off: 1299 2111
Bosnia BIH 197 543
Kosovo KSV ..
Serbia and Montenegro SRB 1059 1262

Poland POL - 634 * * -
Romania ROU 4 301 414 -
Russia RUS 157 700 376 168 41
United Kingdom GBR 641 *
Turkey TUR 76 886 86 207
Ukraine UKR 547
Estonia EST * *
Croatia HRV 140
Lithuania LTU * *
Belarus BLR 88
Germany DEU 829 *
France FRA *
Greece GRC *
Latvia LVA *
Netherlands NLD *


AFRICA of which 1991 2864 259 1155 62
Eritrea ERI 475 190
Ethiopia ETH 37 178 60 43
Somalia SOM 841 770
Uganda UGA 9
Egypt EGY 18
Cameroon CMR 329
Nigeria NGA 301


AMERICA of which 428 2238 1175 998 11
Chile CHL 6 356 -
Colombia COL 332 103 -
Cuba CUB 15
Brazil BRA 143 54 -
Bolivia BOL 10
Guatemala GTM -
Canada CAN 241 363
USA USA 522 629 213
Mexico MEX 168


ASIA of which 3711 7733 2136 3636 645
Afghanistan AFG 387
Bangladesh BGD 44 307
Philippines PHL 373 8
India IND 175 760 592 38
Iraq IRQ 1692 1705
Iran IRN 230 626 44 266
China CHN 36 498 479 934 450
Japan JPN 152 151
Pakistan PAK 35 624
Lebanon LBN 97 277
Sri Lanka LKA 5 85 1
Syria SYR 178 427 32
Thailand THA 2095 329 35
Vietnam 3 283 86
Korea, Republic PRK 9


OCEANIA of which 235 316 280
Australia AUS 265


OTHERS of which 1081 472 14 16 1


TOTAL of which 8859 21908 5985 6837 805
Females 4185 12511 1512 2367 583
Males 4674 9397 4473 4470 222
Loading