Published
Edited
Nov 18, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
aq = require("arquero")
Insert cell
import { Wrangler, op } from "@observablehq/data-wrangler"
Insert cell
Insert cell
timeSeries_values=aq.from(timeSeries)
.select('0','1','2','3','4','5','6','7','8','9','10','artist_song','-13','-12','-11','-10','-9','-8','-7','-6','-5','-4','-3','-2','-1')
.objects() // Uncomment to return an array of objects
Insert cell
Inputs.table(timeSeries_values)
Insert cell
Insert cell
// To use copied code replace "data" with your own variable
timeSeries_values_year=aq.from(timeSeries_values)
.join(aq.from(songRelease), ["artist_song", "artist_song"])
.objects() // Uncomment to return an array of objects
Insert cell
Inputs.table(timeSeries_values_year)
Insert cell
Insert cell
Insert cell
Insert cell
// To use copied code replace "data" with your own variable
noDiggity=aq.from(timeSeries_values_year)
.filter(d => op.match(d["artist_song"], "BLACKstreet"))
.objects() // Uncomment to return an array of objects
Insert cell
Inputs.table(noDiggity)
Insert cell
Insert cell
Insert cell
noDiggity_values=aq.from(noDiggity)
.select('0','1','2','3','4','5','6','7','8','9','10','-13','-12','-11','-10','-9','-8','-7','-6','-5','-4','-3','-2','-1')
.objects()
Insert cell
function round(data){
var x=[];
for(var i=-13;i<11;i++)
{
var y=_math.floor(data[0][i]*100);
var z= noDiggity[0].year;
var birthYear=z+i;
var j=Math.abs(i);
x.push({birth_year:birthYear,remember:y,age:j});
}
return(x);
}
Insert cell
Insert cell
noDiggity_values_round=round(noDiggity_values)
Insert cell
vegaEmbed = require("vega-embed")
Insert cell
Insert cell
Insert cell
Insert cell
Inputs.table(timeSeries_values_year)

Insert cell
### Converting all data to column format by enclosing the function in a while loop
Insert cell
function columnTable(data){
var x=[];
var i=0;
while(i<342){
for(var j=-13; j<11 ;j++)
{
var y=_math.floor(data[i][j]*100);
var z= data[i].year;
var birthYear=z+j;
var m= data[i].artist_song;
x.push({birth_year:birthYear,remember:y,artist_song:m, age:j});
}
i++;
}
return(x);
}
Insert cell
columnData=columnTable(timeSeries_values_year)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
remGrt_90= aq.from(columnData)
.join_right(aq.from(song_90), ["artist_song", "artist_song"])
.objects() // Uncomment to return an array of objects
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
#### Making nearest point work
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function topChartRound(data){
var ar=[];
var i=0;
while(i<344){
for(var j=1; j<3 ;j++)
{
var x =_math.floor(data[i]["mean_millennial_recognition"]*100);
var y=_math.floor(data[i]["mean_gen_z_recognition"]*100);
}
ar.push({artist_song:data[i].artist_song,millennial:x,genZ:y})
i++;
}
return(ar);
}
Insert cell
Insert cell
topChartRound_data=topChartRound(topChartData);

Insert cell
Inputs.table(topChartRound_data)
Insert cell
Insert cell
// To use copied code replace "data" with your own variable
topChartRound_fold=aq.from(topChartRound_data)
.fold(['millennial','genZ']).orderby(aq.desc("value"))
.objects() // Uncomment to return an array of objects
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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