Public
Edited
Oct 2, 2023
8 forks
21 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
maxStatValue = d3.max(weekly, (d) => d.stat);
Insert cell
splitBy = maxStatValue < 50 ? 10 : maxStatValue < 176 ? 25 : maxStatValue < 300 ? 50 : 100;
Insert cell
roundedMaxStatValue = Math.round(maxStatValue / splitBy) * splitBy;
Insert cell
function axisValues(maxStatValue, splitBy) {
const values = [];
for (let i = 0; i <= maxStatValue; i += splitBy) {
values.push(i);
}
return values;
}
Insert cell
Insert cell
Insert cell
Insert cell
db
select b. *
from (
select a. *
,row_number() over () as rank
,(row_number() over ()-1) / 5 as row_num
,row_number() over ()-((row_number() over ()-1) / 5)*5 as col_num
from(
select b.player_id
,p.display_name as player_name
,t.team_abbr
,t.team_logo_espn
,count(distinct week) as games_played
,sum(stat::int)::int as stat
from pbp b
left join players p on p.gsis_id = b.player_id
left join teams t on t.team_abbr = p.team_abbr
where b.player_id <> 'NA' and b.stat <> 'NA'
group by all
having count(distinct week)>=4
order by 6 desc
) a
) b where rank < 26
Insert cell
Insert cell
db = DuckDBClient.of({
pbp: updated_pbp,
players: players,
teams: teams
})
Insert cell
db2 = DuckDBClient.of({
pbp: updated_pbp,
players: players,
teams: teams,
totals: totals
})
Insert cell
Insert cell
pbp.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
players.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
teams.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Map select stat to column name in pbp data before creating queries. Map playerId to respective player entity (e.g. passer_id)
Insert cell
Insert cell
updated_pbp = pbp.map((item) => {
// Calculate the "stat" value based on the "yardline_100" property (you can replace this with your logic)
const stat = item[selectedStat];
const player_id = item[playerId];

// Create a new object with the "stat" property added
return { ...item, stat, player_id };
});
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more