Public
Edited
Sep 11, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
scheduleA2023
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
function filterFilersJustToCouncilAndMayor(data) {
const filtered = data.filter((d) => {
const { filerName } = d;

return filerName.includes("City Council") || filerName.includes("Mayor");
});
return filtered;
}
Insert cell
Insert cell
Insert cell
function filterToJustJanuaryThroughJune(data, y) {
const filtered = data.filter((d) => {
const { date } = d;
const [year, month, day] = date.split("-");
return +month < 7 && +year === y;
});

return filtered;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
overLimits2023 = aggregatedScheduleA2023CouncilAndMayorThroughJune30.filter(
(d) => {
const { filer, amount } = d;
const isForMayor = filer.includes("Mayor");
const isForCouncil = filer.includes("City Council");

if (isForMayor && amount > 67900) return true;
if (isForCouncil && amount > 34000) return true;
return false;
}
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function filterAndAggregateByFilerName(data, year) {
const councilAndMayor = filterFilersJustToCouncilAndMayor(data);
const filtered = filterToJustJanuaryThroughJune(councilAndMayor, year);
const rolled = d3.rollup(
filtered,
(values) => d3.sum(values, (d) => d.amount),
(d) => d.filerName
);
const arr = [];

rolled.forEach((amount, filer) => {
arr.push({
filer,
amount,
year
});
});

const sorted = _.orderBy(arr, ["amount"], ["desc"]);
return sorted;
}
Insert cell
aggregated
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
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