Public
Edited
Nov 2, 2021
Insert cell
Insert cell
Insert cell
aq = require("arquero")
Insert cell
data = aq.fromJSON(raw)
Insert cell
Inputs.table(data)
Insert cell
## Derive
Create a new columns
Insert cell
Inputs.table(derivedData)
Insert cell
Insert cell
recodeObject = ({
top: 1,
center: 0,
bottom: -1
})
Insert cell
derivedData = aq
.from(data)
.params({ recodeObject })
.derive({
// Column Name: function to compute the values of the new column
// idPlus: Function (take the value of id and add one)
idPlus: (d) => d.id + 1,
// sidePlus: (d) => d.side map this transformation given by the recode object
sidePlus: (d) => aq.op.recode(d.side, recodeObject)
})
Insert cell
Insert cell
// Long form Function
function add(d, $) {
return d.id + $.id;
}
Insert cell
// Short form function (Arrow Function)
add1 = (d, $) => d.id + $.id
Insert cell
// No name function (Anonymous Function)
(d, $) => d.id + $.id
Insert cell
add({ id: 2 }, { id: 3 })
Insert cell
add1({ id: 2 }, { id: 3 })
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