Public
Edited
Sep 5, 2023
Insert cell
Insert cell
Insert cell
db = DuckDBClient.of({
batting:battingFile,
people:peopleFile,
teams:teamsFile
})
Insert cell
db
ALTER TABLE batting
ALTER yearID TYPE USMALLINT
Insert cell
db
ALTER TABLE teams
ALTER yearID TYPE USMALLINT
Insert cell
db
SELECT
max(nameFirst),
max(nameLast),
batting.playerID,
replace(batting.yearID,',',''),
IF(
max(name) == min(name),
max(name),
CONCAT(min(name),'/',max(name))
),
sum(batting.HR) AS seasonHR
FROM batting INNER JOIN people
ON batting.playerID = people.playerID
INNER JOIN teams
ON batting.teamID = teams.teamID AND batting.yearID = teams.yearID
GROUP BY batting.playerID,batting.yearID
HAVING seasonHR >= 50
ORDER BY seasonHR DESC
Insert cell
db
SELECT max(name) AS name
FROM teams
GROUP BY name
Insert cell
Insert cell
db
SELECT name,yearID,HR
FROM teams
WHERE name = ${name}
Insert cell
Insert cell
Plot.plot({
x:{domain:[1850,2022],tickFormat:".0f"},
y:{domain:[0,310]},
marks:[
Plot.ruleX([1900]),
Plot.ruleY([0]),
Plot.line(data,{x:"yearID",y:"HR"})
]
})
Insert cell
Insert cell
Insert cell
Insert cell
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