Public
Edited
Apr 29, 2023
1 fork
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {Plot} from "@mkfreeman/plot-tooltip"
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.gridX({stroke:"black"}),
Plot.dot(instructor_classes,
Plot.dodgeY({x: "avg_diff",
fill:"#E13026",
title: (d) =>
`${d.instructor} \n ${d.avg_diff}`,
// center points in swarm
r:"workouts",
anchor:"middle"}),
),
//customize X axis
Plot.axisX({tickSize:0,
fontSize:15})
],
height:400,
width:800,
marginBottom:50,
marginLeft:50,
marginRight:50,
style:{
backgroundColor:"white",
color:"black"
}
})
Insert cell
Select a data source…
Type SQL, then Shift-Enter. Ctrl-space for more options.

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

Insert cell
Insert cell
peloton_data
SELECT
id
,ride_image
,instructor
,end_time
,avg_difficulty
,CAST(total_output as int) total_output
FROM peloton_data
WHERE fitness_discipline = 'cycling' and total_output <> 'NA' and ride_duration = 30*60
Insert cell
peloton_data
SELECT
instructor
,CONCAT('https://raw.githubusercontent.com/tashapiro/peloton-stats/main/images/instructors/circle/',REPLACE(instructor,' ','_'),'.png') as src
,ROUND(sum(avg_difficulty * ride_duration)/sum(ride_duration),2) as avg_diff
,COUNT(id)::int as workouts
FROM peloton_data
WHERE avg_difficulty>0 and avg_difficulty<10 and instructor!='NA'
GROUP BY instructor
HAVING workouts>2
Insert cell
peloton_data
SELECT * FROM(
SELECT
instructor
,CONCAT('https://raw.githubusercontent.com/tashapiro/peloton-stats/main/images/instructors/circle/',REPLACE(instructor,' ','_'),'.png') as src
,CAST(sum(CAST(ride_duration as int)) as int)/60 as minutes
--,cast(count(fitness_discipline) as int) as workouts
-- ,CAST(sum(CAST(distance as numeric)) as int) as miles
FROM peloton_data
WHERE fitness_discipline = ${workout_type} and ride_duration>0 and instructor<>'NA'
GROUP BY 1
ORDER BY 3 desc)
LIMIT 7
Insert cell
Insert cell
viewof date = Inputs.date({label: "Date", value: "2023-04-29"})
Insert cell
viewof table = Inputs.table(cars)
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