Public
Edited
Nov 2, 2023
Insert cell
Insert cell
Insert cell
{
const value = `a,"b","a,b",'1,2'`
const commasNotInQuotes = /,(?=(?:[^"]|"[^"]*")*$)(?=(?:[^']|'[^']*')*$)/g
const splitValue = value.split(commasNotInQuotes)
const removeQuotes = /^['"](.*)['"]$/
const cleanValue = splitValue.map((val) => {
const match = val.match(removeQuotes)
return match ? match[1] : val
})
return cleanValue
}
Insert cell
aq = require('arquero')
Insert cell
data = aq.table(company_columnar)
Insert cell
company_columnar = FileAttachment("company_columnar.json").json()
Insert cell
matches = FileAttachment("matches.json").json()
Insert cell
data.groupby(["consumer_brand","uml_id"]).derive(d => d.report_year).objects()
Insert cell
iters = 100_000
Insert cell
function zeros(n) {
let vector = [];
for (let i = 0; i < n; i++) {
vector.push(0);
}
return vector;
}
Insert cell
modernZeros = (n) => Array.from(n).fill( () => 0)
Insert cell
{
let t0 = performance.now()
// for (let i=0; i<iters;i++){
// zeros(10000)
// }
// const timeOld = performance.now() - t0
t0 = performance.now()
for (let i=0; i<iters;i++){
modernZeros(10000)
}
const timeModern = performance.now() - t0
// t0 = performance.now()
// for (let i=0; i<iters;i++){
// _.times(10000, _.constant(0));
// }
// const timeLodash = performance.now() - t0
// t0 = performance.now()
// for (let i=0; i<iters;i++){
// radash.list(0,10000,0)
// }
// const timeRadash = performance.now() - t0

return {
// timeOld,
timeModern,
// timeLodash,
// timeRadash
}
}
Insert cell
radash = import('https://cdn.skypack.dev/radash')
Insert cell
radash.list(1, 10000, 0)
Insert cell
treeCoverData = ({"0": "379042", "1": "77", "2": "71", "3": "80", "4": "459", "5": "119", "6": "279", "7": "29", "8": "40", "9": "288", "10": "156", "11": "83", "12": "1059", "13": "177", "14": "219", "15": "302", "16": "90", "17": "365", "18": "241", "19": "98", "20": "517", "21": "203", "22": "281", "23": "12", "24": "145", "25": "179", "26": "143", "27": "442", "28": "319", "29": "202", "30": "64", "31": "359", "32": "376", "33": "243", "34": "48", "35": "75", "36": "169", "37": "675", "38": "38", "39": "159", "40": "131", "41": "180", "42": "83", "43": "266", "44": "632", "45": "1180", "46": "75", "47": "1034", "48": "390", "49": "516", "50": "61", "51": "878", "52": "430", "53": "165", "54": "660", "55": "892", "56": "880", "57": "184", "58": "1492", "59": "595", "60": "512", "61": "125", "62": "822", "63": "834", "64": "1227", "65": "57", "66": "509", "67": "567", "68": "630", "69": "55", "70": "1155", "71": "972", "72": "2404", "73": "148", "74": "2018", "75": "2264", "76": "5036", "77": "594", "78": "3330", "79": "1086", "80": "179", "81": "1070", "82": "4035", "83": "4702", "84": "106", "85": "10814", "86": "4365", "87": "11053", "88": "449", "89": "21566", "90": "28298", "91": "2593", "92": "3454", "93": "614", "94": "1179", "95": "23940", "96": "2646", "97": "95615", "98": "145182", "99": "922", "100": "5436"})
Insert cell
forestPx = Object.entries(treeCoverData).reduce((curr,acc) => curr + ((parseInt(acc[0])/100)*parseInt(acc[1])), 0)
Insert cell
342266393 / 100000
Insert cell
(forestPx * (30**2)) / 100000
Insert cell
Object.entries(treeCoverData)
Insert cell
main = async () => {
const t0 = performance.now()
await fetch('https://d3lsdszfx9jqxt.cloudfront.net/data-query/65405b33c1356c000878d9f7?format=msgpack')
const t1 = performance.now()
return t1-t0
}
Insert cell
main()
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