Published
Edited
Dec 10, 2021
Insert cell
Insert cell
Insert cell
formatted = data
// .filter(function(d) {
// let deleteRow = true;
// for (const key in d) {
// if (key != "Institution Name" && d[key] != null) deleteRow = false;
// }
// return !deleteRow;
// })
.map(function (d) {
const newObj = {};
for (const key in d) {
let newKey = key;
if (
!(
key == "Institution Name" ||
key == "UnitID" ||
key.startsWith("FIPS")
) &&
key
) {
const strings = key.trim().split(" ");
console.log(strings);
const year = +strings[1].slice(2, 6);
const majornum = +strings[3].slice(9, 10);
const cipcode = +strings[7].slice(8, -1);
const awlevel = +strings[5].slice(8);

newKey = `Total_${year}_M${majornum}_CIP${cipcode}_AL${awlevel}`;
}
newObj[newKey] = d[key];
}

return newObj;
})
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