Published
Edited
Mar 7, 2019
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
countriesList = Object.keys(z.valueCounts(colBirthCountries))
// colBirthCountries gets reduced to unique entries by valueCounts. since it's technically still a df we use Object.Keys to pull out just the country names

Insert cell
Insert cell
Insert cell
Insert cell
Countries = z.unique(z.getCol("Country",Data))
// array of all the countries that migrants flow in and out of
Insert cell
inflows = {
let newString = []
for (var i = 0; i< Countries.length; i++) {
let DF = z.filter(r=> r["Country"] == Countries[i] && r["Variable"] == "Inflows of foreign population by nationality", Data)
// creates a dataframe (DF) that consists only of the country in question & its inflows
let val = z.getCol("Value", DF)
//grabs the column w inflow values
let valParse = parseArray(val)
// makes column entries ints instead of strings
let total = addArray(valParse)
// uses addArray (in appendix) to sum all of the inflow values
newString.push(total)
//adds the sum to new string
}
return newString
}
Insert cell
// outflows & stock are the same code as inflows, but pull outflows/stocks into the data frame of the for loop's first line
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//df4 is a data frame containing just the country codes & the continent
Insert cell
joined = z.merge(Data, moreData,"COU", "Three_Letter_Country_Code", "da", "moreDa")
// data sets joined by country code
Insert cell
Insert cell
//next I would appropriately sort countriesWithCodes & df4, and join them into a single data frame by the shared codes
//after they are joined, I'd sort through them and remove repeated countries
//then I would join this cleaned dataframe with my dataframe from part 3, which contains the inflows, outflows, etc, by country name
Insert cell
Insert cell
// Your code here

Insert cell
// Your code here

Insert cell
// Your code here

Insert cell
Insert cell
// Your code here

Insert cell
// Your code here

Insert cell
// Your code here

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//takes in a array of strings and gives me back the strings as ints
Insert cell
Insert cell
//this grabs the first word of a string
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more