Public
Edited
May 12, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
my_data = {
var result = []

//This is my process of cleaning and reconciling the data
birthdeath.forEach(person => {
//starting with the birthdeath table
//for each person in it, we are going to get some more information
var cleanedOccupations = []
var personOccupations = occupation.filter(d => d.URI == person.URI) //occupations of this person
var searchLocations = locations.filter(d => d.URI == person.URI) //locations of this prson
var personLocations = []
//if there are known locations
if (searchLocations.length > 0)
searchLocations.forEach(loc => {
var locationLabel = loc.event_label.split(":")
var simpleLocationLabel = locationLabel[locationLabel.length-1].trim()
personLocations.push({
placeLabel: loc.placeLabel,
locationType: loc.locationType.replace("http://id.lincsproject.ca/cwrc/", ""),
latitude: loc.latitude.replace(",", "."), //cleaning location data by replacing comma by point
longitude: loc.longitude.replace(",", "."),
eventLabel: simpleLocationLabel
}) //add the location
})

//finding the cause(s) of death
var searchDeath = causedeath.filter(d => d.URI == person.URI)
var causeDeath = []

if ( searchDeath.length == 0) // if there are none, write unknown
causeDeath.push("unknown causes")
else if (searchDeath.length == 1) // if there is one, add it's label
causeDeath.push(searchDeath[0].cause_label)
else {
causeDeath = []
searchDeath.forEach(d => causeDeath.push(d.cause_label)) //if there are several, add their labels
}
//for each occupation, add the title and type of employment
personOccupations.forEach(occ => {
cleanedOccupations.push({
job: occ.job_title,
type: occ.type_of_employment
})
})

//this is the resulting data we are creating for each person
result.push({
name: person.name,
firstName: person.name.split(",")[1] ? person.name.split(",")[1].trim() : "", //attempt to get the first name
lastName: person.name.split(",")[0] ? person.name.split(",")[0].trim() : "", //attempt to get the last name
birth: person.birth_Year,
death: person.death_Year,
ageAtDeath: person.death_Year - person.birth_Year,
uri: person.URI,
occupation: cleanedOccupations,
causeDeath : causeDeath,
locations: personLocations
})
})
return result
}
Insert cell
individuals = my_data.map(d => d.name)
Insert cell
Insert cell
Insert cell
checkLocations = my_data.filter(d => d.locations.length != 0)
Insert cell
Insert cell
Insert cell
Insert cell
## Locations
Insert cell
map = {
const container = yield htl.html`<div style="height: 500px;">`;
const map = L.map(container).setView([43.5460516, -80.2493276], 3);
locations.forEach(l => {
L.marker([l.latitude.replace(",","."), l.longitude.replace(",",".")]).addTo(map)
.bindPopup(`${l.placeLabel}<br>${l.URI}`);
})
}
Insert cell
data
Type SQL, then Shift-Enter. Ctrl-space for more options.

Insert cell
Object.keys(locations[0])
Insert cell
Insert cell
Insert cell
Object.keys(occupation[0])
Insert cell
test = {
var result = [];
var totalOccupationsDocumented = occupation.length
console.log("Documented occupations", totalOccupationsDocumented)
console.log("Dinstinct occupations", distinctOccupations.length)
distinctOccupations.forEach(occ => {
var subset = occupation.filter(d => d.job_title == occ.job_title)
result.push({
occupation: occ.job_title,
nb: subset.length,
percentage: subset.length * 100 / totalOccupationsDocumented,
data: subset
})
})
return result.sort((a ,b) => b.nb - a.nb)
}
Insert cell
data
SELECT job_title, COUNT(job_title)
FROM Occupation
GROUP BY job_title
Insert cell
Insert cell
Insert cell
data
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
data
SELECT DISTINCT (name), death_Year - birth_Year as life, birth_Year, death_Year, cause_label, job_title, type_of_employment
FROM BirthDeath
INNER JOIN CauseDeath
ON BirthDeath.URI=CauseDeath.URI
INNER JOIN Occupation
ON BirthDeath.URI=Occupation.URI
Insert cell
data = DuckDBClient.of({
BirthDeath: birthdeath,
CauseDeath: causedeath,
Locations: locations,
Occupation: occupation
})
Insert cell
birthdeath
Type SQL, then Shift-Enter. Ctrl-space for more options.

Insert cell
birthDeath.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
occupation.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
birthdeath.length
Insert cell
causedeath.length
Insert cell
causeDeath.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
locations.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
data
Type SQL, then Shift-Enter. Ctrl-space for more options.

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