From 3b73d77f0b98f2380597d6211946ec00bf3ed91c Mon Sep 17 00:00:00 2001 From: Gordon Shotwell Date: Thu, 4 Apr 2024 13:09:51 -0300 Subject: [PATCH 1/4] Add additional exercises pages --- .../3.1-update-slider/README | 4 - .../3.1-update-slider/app-solution.py | 48 --- .../3.1-update-slider/app.py | 42 --- .../3.1-update-slider/penguins.csv | 345 ------------------ .../README | 0 .../app-solution.py | 0 .../app.py | 0 .../data_import.py | 0 .../plots.py | 0 .../simulated-data.csv | 0 .../README.md | 0 .../app-solution.py | 0 .../app.py | 0 .../data_import.py | 0 .../plots.py | 0 .../simulated-data.csv | 0 .../README.md | 0 .../app-solution.py | 0 .../app.py | 0 .../data_import.py | 0 .../plots.py | 0 .../simulated-data.csv | 0 exercises/2-basic-ui.qmd | 0 exercises/3-reactivity.qmd | 0 exercises/4-dynamic-ui.qmd | 0 exercises/5-reactive-effect.qmd | 19 + 26 files changed, 19 insertions(+), 439 deletions(-) delete mode 100644 apps/problem-sets/3-reactive-effects/3.1-update-slider/README delete mode 100644 apps/problem-sets/3-reactive-effects/3.1-update-slider/app-solution.py delete mode 100644 apps/problem-sets/3-reactive-effects/3.1-update-slider/app.py delete mode 100644 apps/problem-sets/3-reactive-effects/3.1-update-slider/penguins.csv rename apps/problem-sets/3-reactivity/{3.1-reactive.calc => 3.1-reactive-calc}/README (100%) rename apps/problem-sets/3-reactivity/{3.1-reactive.calc => 3.1-reactive-calc}/app-solution.py (100%) rename apps/problem-sets/3-reactivity/{3.1-reactive.calc => 3.1-reactive-calc}/app.py (100%) rename apps/problem-sets/3-reactivity/{3.1-reactive.calc => 3.1-reactive-calc}/data_import.py (100%) rename apps/problem-sets/3-reactivity/{3.1-reactive.calc => 3.1-reactive-calc}/plots.py (100%) rename apps/problem-sets/3-reactivity/{3.1-reactive.calc => 3.1-reactive-calc}/simulated-data.csv (100%) rename apps/problem-sets/5-reactive-effects/{5.1-reactive.event => 5.1-reactive-event}/README.md (100%) rename apps/problem-sets/5-reactive-effects/{5.1-reactive.event => 5.1-reactive-event}/app-solution.py (100%) rename apps/problem-sets/5-reactive-effects/{5.1-reactive.event => 5.1-reactive-event}/app.py (100%) rename apps/problem-sets/5-reactive-effects/{5.1-reactive.event => 5.1-reactive-event}/data_import.py (100%) rename apps/problem-sets/5-reactive-effects/{5.1-reactive.event => 5.1-reactive-event}/plots.py (100%) rename apps/problem-sets/5-reactive-effects/{5.1-reactive.event => 5.1-reactive-event}/simulated-data.csv (100%) rename apps/problem-sets/5-reactive-effects/{5.2-reactive.effect => 5.2-reactive-effect}/README.md (100%) rename apps/problem-sets/5-reactive-effects/{5.2-reactive.effect => 5.2-reactive-effect}/app-solution.py (100%) rename apps/problem-sets/5-reactive-effects/{5.2-reactive.effect => 5.2-reactive-effect}/app.py (100%) rename apps/problem-sets/5-reactive-effects/{5.2-reactive.effect => 5.2-reactive-effect}/data_import.py (100%) rename apps/problem-sets/5-reactive-effects/{5.2-reactive.effect => 5.2-reactive-effect}/plots.py (100%) rename apps/problem-sets/5-reactive-effects/{5.2-reactive.effect => 5.2-reactive-effect}/simulated-data.csv (100%) create mode 100644 exercises/2-basic-ui.qmd create mode 100644 exercises/3-reactivity.qmd create mode 100644 exercises/4-dynamic-ui.qmd create mode 100644 exercises/5-reactive-effect.qmd diff --git a/apps/problem-sets/3-reactive-effects/3.1-update-slider/README b/apps/problem-sets/3-reactive-effects/3.1-update-slider/README deleted file mode 100644 index a16a693..0000000 --- a/apps/problem-sets/3-reactive-effects/3.1-update-slider/README +++ /dev/null @@ -1,4 +0,0 @@ -It's often a good idea to allow users of your application to reset input values to their initial state. -Take this simple application and add a `ui.action_button` which resets the slider. - -You should use one of the `ui.update_*` functions listed in the [documentation](https://shiny.rstudio.com/py/api/) \ No newline at end of file diff --git a/apps/problem-sets/3-reactive-effects/3.1-update-slider/app-solution.py b/apps/problem-sets/3-reactive-effects/3.1-update-slider/app-solution.py deleted file mode 100644 index 0fd0446..0000000 --- a/apps/problem-sets/3-reactive-effects/3.1-update-slider/app-solution.py +++ /dev/null @@ -1,48 +0,0 @@ -from shiny import App, render, ui, reactive -import pandas as pd -from pathlib import Path - -infile = Path(__file__).parent / "penguins.csv" -penguins = pd.read_csv(infile) - -app_ui = ui.page_fluid( - ui.panel_title("Hello Penguins!"), - ui.layout_sidebar( - ui.panel_sidebar( - ui.input_slider( - "mass", - "Mass", - 2000, - 8000, - 6000, - ), - ui.input_action_button("reset", "Reset Slider"), - ), - ui.panel_main( - ui.output_data_frame("table"), - ), - ), -) - - -def server(input, output, session): - @output - @render.data_frame - def table(): - df = penguins.copy() - filtered = df.loc[df["body_mass"] < input.mass()] - summary = ( - filtered.set_index("species") - .groupby(level="species") - .agg({"bill_length": "mean", "bill_depth": "mean"}) - .reset_index() - ) - return summary - - @reactive.Effect - @reactive.event(input.reset) - def _reset_slider(): - ui.update_slider("mass", value=6000) - - -app = App(app_ui, server) diff --git a/apps/problem-sets/3-reactive-effects/3.1-update-slider/app.py b/apps/problem-sets/3-reactive-effects/3.1-update-slider/app.py deleted file mode 100644 index 4dc5ec9..0000000 --- a/apps/problem-sets/3-reactive-effects/3.1-update-slider/app.py +++ /dev/null @@ -1,42 +0,0 @@ -from shiny import App, render, ui -import pandas as pd -from pathlib import Path - -infile = Path(__file__).parent / "penguins.csv" -penguins = pd.read_csv(infile) - -app_ui = ui.page_fluid( - ui.panel_title("Hello Penguins!"), - ui.layout_sidebar( - ui.panel_sidebar( - ui.input_slider( - "mass", - "Mass", - 2000, - 8000, - 6000, - ), - ), - ui.panel_main( - ui.output_data_frame("table"), - ), - ), -) - - -def server(input, output, session): - @output - @render.data_frame - def table(): - df = penguins.copy() - filtered = df.loc[df["body_mass"] < input.mass()] - summary = ( - filtered.set_index("species") - .groupby(level="species") - .agg({"bill_length": "mean", "bill_depth": "mean"}) - .reset_index() - ) - return summary - - -app = App(app_ui, server) diff --git a/apps/problem-sets/3-reactive-effects/3.1-update-slider/penguins.csv b/apps/problem-sets/3-reactive-effects/3.1-update-slider/penguins.csv deleted file mode 100644 index d8cca02..0000000 --- a/apps/problem-sets/3-reactive-effects/3.1-update-slider/penguins.csv +++ /dev/null @@ -1,345 +0,0 @@ -species,island,bill_length,bill_depth,flipper_length,body_mass,sex,year -Adelie,Torgersen,39.1,18.7,181,3750,male,2007 -Adelie,Torgersen,39.5,17.4,186,3800,female,2007 -Adelie,Torgersen,40.3,18,195,3250,female,2007 -Adelie,Torgersen,NA,NA,NA,NA,NA,2007 -Adelie,Torgersen,36.7,19.3,193,3450,female,2007 -Adelie,Torgersen,39.3,20.6,190,3650,male,2007 -Adelie,Torgersen,38.9,17.8,181,3625,female,2007 -Adelie,Torgersen,39.2,19.6,195,4675,male,2007 -Adelie,Torgersen,34.1,18.1,193,3475,NA,2007 -Adelie,Torgersen,42,20.2,190,4250,NA,2007 -Adelie,Torgersen,37.8,17.1,186,3300,NA,2007 -Adelie,Torgersen,37.8,17.3,180,3700,NA,2007 -Adelie,Torgersen,41.1,17.6,182,3200,female,2007 -Adelie,Torgersen,38.6,21.2,191,3800,male,2007 -Adelie,Torgersen,34.6,21.1,198,4400,male,2007 -Adelie,Torgersen,36.6,17.8,185,3700,female,2007 -Adelie,Torgersen,38.7,19,195,3450,female,2007 -Adelie,Torgersen,42.5,20.7,197,4500,male,2007 -Adelie,Torgersen,34.4,18.4,184,3325,female,2007 -Adelie,Torgersen,46,21.5,194,4200,male,2007 -Adelie,Biscoe,37.8,18.3,174,3400,female,2007 -Adelie,Biscoe,37.7,18.7,180,3600,male,2007 -Adelie,Biscoe,35.9,19.2,189,3800,female,2007 -Adelie,Biscoe,38.2,18.1,185,3950,male,2007 -Adelie,Biscoe,38.8,17.2,180,3800,male,2007 -Adelie,Biscoe,35.3,18.9,187,3800,female,2007 -Adelie,Biscoe,40.6,18.6,183,3550,male,2007 -Adelie,Biscoe,40.5,17.9,187,3200,female,2007 -Adelie,Biscoe,37.9,18.6,172,3150,female,2007 -Adelie,Biscoe,40.5,18.9,180,3950,male,2007 -Adelie,Dream,39.5,16.7,178,3250,female,2007 -Adelie,Dream,37.2,18.1,178,3900,male,2007 -Adelie,Dream,39.5,17.8,188,3300,female,2007 -Adelie,Dream,40.9,18.9,184,3900,male,2007 -Adelie,Dream,36.4,17,195,3325,female,2007 -Adelie,Dream,39.2,21.1,196,4150,male,2007 -Adelie,Dream,38.8,20,190,3950,male,2007 -Adelie,Dream,42.2,18.5,180,3550,female,2007 -Adelie,Dream,37.6,19.3,181,3300,female,2007 -Adelie,Dream,39.8,19.1,184,4650,male,2007 -Adelie,Dream,36.5,18,182,3150,female,2007 -Adelie,Dream,40.8,18.4,195,3900,male,2007 -Adelie,Dream,36,18.5,186,3100,female,2007 -Adelie,Dream,44.1,19.7,196,4400,male,2007 -Adelie,Dream,37,16.9,185,3000,female,2007 -Adelie,Dream,39.6,18.8,190,4600,male,2007 -Adelie,Dream,41.1,19,182,3425,male,2007 -Adelie,Dream,37.5,18.9,179,2975,NA,2007 -Adelie,Dream,36,17.9,190,3450,female,2007 -Adelie,Dream,42.3,21.2,191,4150,male,2007 -Adelie,Biscoe,39.6,17.7,186,3500,female,2008 -Adelie,Biscoe,40.1,18.9,188,4300,male,2008 -Adelie,Biscoe,35,17.9,190,3450,female,2008 -Adelie,Biscoe,42,19.5,200,4050,male,2008 -Adelie,Biscoe,34.5,18.1,187,2900,female,2008 -Adelie,Biscoe,41.4,18.6,191,3700,male,2008 -Adelie,Biscoe,39,17.5,186,3550,female,2008 -Adelie,Biscoe,40.6,18.8,193,3800,male,2008 -Adelie,Biscoe,36.5,16.6,181,2850,female,2008 -Adelie,Biscoe,37.6,19.1,194,3750,male,2008 -Adelie,Biscoe,35.7,16.9,185,3150,female,2008 -Adelie,Biscoe,41.3,21.1,195,4400,male,2008 -Adelie,Biscoe,37.6,17,185,3600,female,2008 -Adelie,Biscoe,41.1,18.2,192,4050,male,2008 -Adelie,Biscoe,36.4,17.1,184,2850,female,2008 -Adelie,Biscoe,41.6,18,192,3950,male,2008 -Adelie,Biscoe,35.5,16.2,195,3350,female,2008 -Adelie,Biscoe,41.1,19.1,188,4100,male,2008 -Adelie,Torgersen,35.9,16.6,190,3050,female,2008 -Adelie,Torgersen,41.8,19.4,198,4450,male,2008 -Adelie,Torgersen,33.5,19,190,3600,female,2008 -Adelie,Torgersen,39.7,18.4,190,3900,male,2008 -Adelie,Torgersen,39.6,17.2,196,3550,female,2008 -Adelie,Torgersen,45.8,18.9,197,4150,male,2008 -Adelie,Torgersen,35.5,17.5,190,3700,female,2008 -Adelie,Torgersen,42.8,18.5,195,4250,male,2008 -Adelie,Torgersen,40.9,16.8,191,3700,female,2008 -Adelie,Torgersen,37.2,19.4,184,3900,male,2008 -Adelie,Torgersen,36.2,16.1,187,3550,female,2008 -Adelie,Torgersen,42.1,19.1,195,4000,male,2008 -Adelie,Torgersen,34.6,17.2,189,3200,female,2008 -Adelie,Torgersen,42.9,17.6,196,4700,male,2008 -Adelie,Torgersen,36.7,18.8,187,3800,female,2008 -Adelie,Torgersen,35.1,19.4,193,4200,male,2008 -Adelie,Dream,37.3,17.8,191,3350,female,2008 -Adelie,Dream,41.3,20.3,194,3550,male,2008 -Adelie,Dream,36.3,19.5,190,3800,male,2008 -Adelie,Dream,36.9,18.6,189,3500,female,2008 -Adelie,Dream,38.3,19.2,189,3950,male,2008 -Adelie,Dream,38.9,18.8,190,3600,female,2008 -Adelie,Dream,35.7,18,202,3550,female,2008 -Adelie,Dream,41.1,18.1,205,4300,male,2008 -Adelie,Dream,34,17.1,185,3400,female,2008 -Adelie,Dream,39.6,18.1,186,4450,male,2008 -Adelie,Dream,36.2,17.3,187,3300,female,2008 -Adelie,Dream,40.8,18.9,208,4300,male,2008 -Adelie,Dream,38.1,18.6,190,3700,female,2008 -Adelie,Dream,40.3,18.5,196,4350,male,2008 -Adelie,Dream,33.1,16.1,178,2900,female,2008 -Adelie,Dream,43.2,18.5,192,4100,male,2008 -Adelie,Biscoe,35,17.9,192,3725,female,2009 -Adelie,Biscoe,41,20,203,4725,male,2009 -Adelie,Biscoe,37.7,16,183,3075,female,2009 -Adelie,Biscoe,37.8,20,190,4250,male,2009 -Adelie,Biscoe,37.9,18.6,193,2925,female,2009 -Adelie,Biscoe,39.7,18.9,184,3550,male,2009 -Adelie,Biscoe,38.6,17.2,199,3750,female,2009 -Adelie,Biscoe,38.2,20,190,3900,male,2009 -Adelie,Biscoe,38.1,17,181,3175,female,2009 -Adelie,Biscoe,43.2,19,197,4775,male,2009 -Adelie,Biscoe,38.1,16.5,198,3825,female,2009 -Adelie,Biscoe,45.6,20.3,191,4600,male,2009 -Adelie,Biscoe,39.7,17.7,193,3200,female,2009 -Adelie,Biscoe,42.2,19.5,197,4275,male,2009 -Adelie,Biscoe,39.6,20.7,191,3900,female,2009 -Adelie,Biscoe,42.7,18.3,196,4075,male,2009 -Adelie,Torgersen,38.6,17,188,2900,female,2009 -Adelie,Torgersen,37.3,20.5,199,3775,male,2009 -Adelie,Torgersen,35.7,17,189,3350,female,2009 -Adelie,Torgersen,41.1,18.6,189,3325,male,2009 -Adelie,Torgersen,36.2,17.2,187,3150,female,2009 -Adelie,Torgersen,37.7,19.8,198,3500,male,2009 -Adelie,Torgersen,40.2,17,176,3450,female,2009 -Adelie,Torgersen,41.4,18.5,202,3875,male,2009 -Adelie,Torgersen,35.2,15.9,186,3050,female,2009 -Adelie,Torgersen,40.6,19,199,4000,male,2009 -Adelie,Torgersen,38.8,17.6,191,3275,female,2009 -Adelie,Torgersen,41.5,18.3,195,4300,male,2009 -Adelie,Torgersen,39,17.1,191,3050,female,2009 -Adelie,Torgersen,44.1,18,210,4000,male,2009 -Adelie,Torgersen,38.5,17.9,190,3325,female,2009 -Adelie,Torgersen,43.1,19.2,197,3500,male,2009 -Adelie,Dream,36.8,18.5,193,3500,female,2009 -Adelie,Dream,37.5,18.5,199,4475,male,2009 -Adelie,Dream,38.1,17.6,187,3425,female,2009 -Adelie,Dream,41.1,17.5,190,3900,male,2009 -Adelie,Dream,35.6,17.5,191,3175,female,2009 -Adelie,Dream,40.2,20.1,200,3975,male,2009 -Adelie,Dream,37,16.5,185,3400,female,2009 -Adelie,Dream,39.7,17.9,193,4250,male,2009 -Adelie,Dream,40.2,17.1,193,3400,female,2009 -Adelie,Dream,40.6,17.2,187,3475,male,2009 -Adelie,Dream,32.1,15.5,188,3050,female,2009 -Adelie,Dream,40.7,17,190,3725,male,2009 -Adelie,Dream,37.3,16.8,192,3000,female,2009 -Adelie,Dream,39,18.7,185,3650,male,2009 -Adelie,Dream,39.2,18.6,190,4250,male,2009 -Adelie,Dream,36.6,18.4,184,3475,female,2009 -Adelie,Dream,36,17.8,195,3450,female,2009 -Adelie,Dream,37.8,18.1,193,3750,male,2009 -Adelie,Dream,36,17.1,187,3700,female,2009 -Adelie,Dream,41.5,18.5,201,4000,male,2009 -Gentoo,Biscoe,46.1,13.2,211,4500,female,2007 -Gentoo,Biscoe,50,16.3,230,5700,male,2007 -Gentoo,Biscoe,48.7,14.1,210,4450,female,2007 -Gentoo,Biscoe,50,15.2,218,5700,male,2007 -Gentoo,Biscoe,47.6,14.5,215,5400,male,2007 -Gentoo,Biscoe,46.5,13.5,210,4550,female,2007 -Gentoo,Biscoe,45.4,14.6,211,4800,female,2007 -Gentoo,Biscoe,46.7,15.3,219,5200,male,2007 -Gentoo,Biscoe,43.3,13.4,209,4400,female,2007 -Gentoo,Biscoe,46.8,15.4,215,5150,male,2007 -Gentoo,Biscoe,40.9,13.7,214,4650,female,2007 -Gentoo,Biscoe,49,16.1,216,5550,male,2007 -Gentoo,Biscoe,45.5,13.7,214,4650,female,2007 -Gentoo,Biscoe,48.4,14.6,213,5850,male,2007 -Gentoo,Biscoe,45.8,14.6,210,4200,female,2007 -Gentoo,Biscoe,49.3,15.7,217,5850,male,2007 -Gentoo,Biscoe,42,13.5,210,4150,female,2007 -Gentoo,Biscoe,49.2,15.2,221,6300,male,2007 -Gentoo,Biscoe,46.2,14.5,209,4800,female,2007 -Gentoo,Biscoe,48.7,15.1,222,5350,male,2007 -Gentoo,Biscoe,50.2,14.3,218,5700,male,2007 -Gentoo,Biscoe,45.1,14.5,215,5000,female,2007 -Gentoo,Biscoe,46.5,14.5,213,4400,female,2007 -Gentoo,Biscoe,46.3,15.8,215,5050,male,2007 -Gentoo,Biscoe,42.9,13.1,215,5000,female,2007 -Gentoo,Biscoe,46.1,15.1,215,5100,male,2007 -Gentoo,Biscoe,44.5,14.3,216,4100,NA,2007 -Gentoo,Biscoe,47.8,15,215,5650,male,2007 -Gentoo,Biscoe,48.2,14.3,210,4600,female,2007 -Gentoo,Biscoe,50,15.3,220,5550,male,2007 -Gentoo,Biscoe,47.3,15.3,222,5250,male,2007 -Gentoo,Biscoe,42.8,14.2,209,4700,female,2007 -Gentoo,Biscoe,45.1,14.5,207,5050,female,2007 -Gentoo,Biscoe,59.6,17,230,6050,male,2007 -Gentoo,Biscoe,49.1,14.8,220,5150,female,2008 -Gentoo,Biscoe,48.4,16.3,220,5400,male,2008 -Gentoo,Biscoe,42.6,13.7,213,4950,female,2008 -Gentoo,Biscoe,44.4,17.3,219,5250,male,2008 -Gentoo,Biscoe,44,13.6,208,4350,female,2008 -Gentoo,Biscoe,48.7,15.7,208,5350,male,2008 -Gentoo,Biscoe,42.7,13.7,208,3950,female,2008 -Gentoo,Biscoe,49.6,16,225,5700,male,2008 -Gentoo,Biscoe,45.3,13.7,210,4300,female,2008 -Gentoo,Biscoe,49.6,15,216,4750,male,2008 -Gentoo,Biscoe,50.5,15.9,222,5550,male,2008 -Gentoo,Biscoe,43.6,13.9,217,4900,female,2008 -Gentoo,Biscoe,45.5,13.9,210,4200,female,2008 -Gentoo,Biscoe,50.5,15.9,225,5400,male,2008 -Gentoo,Biscoe,44.9,13.3,213,5100,female,2008 -Gentoo,Biscoe,45.2,15.8,215,5300,male,2008 -Gentoo,Biscoe,46.6,14.2,210,4850,female,2008 -Gentoo,Biscoe,48.5,14.1,220,5300,male,2008 -Gentoo,Biscoe,45.1,14.4,210,4400,female,2008 -Gentoo,Biscoe,50.1,15,225,5000,male,2008 -Gentoo,Biscoe,46.5,14.4,217,4900,female,2008 -Gentoo,Biscoe,45,15.4,220,5050,male,2008 -Gentoo,Biscoe,43.8,13.9,208,4300,female,2008 -Gentoo,Biscoe,45.5,15,220,5000,male,2008 -Gentoo,Biscoe,43.2,14.5,208,4450,female,2008 -Gentoo,Biscoe,50.4,15.3,224,5550,male,2008 -Gentoo,Biscoe,45.3,13.8,208,4200,female,2008 -Gentoo,Biscoe,46.2,14.9,221,5300,male,2008 -Gentoo,Biscoe,45.7,13.9,214,4400,female,2008 -Gentoo,Biscoe,54.3,15.7,231,5650,male,2008 -Gentoo,Biscoe,45.8,14.2,219,4700,female,2008 -Gentoo,Biscoe,49.8,16.8,230,5700,male,2008 -Gentoo,Biscoe,46.2,14.4,214,4650,NA,2008 -Gentoo,Biscoe,49.5,16.2,229,5800,male,2008 -Gentoo,Biscoe,43.5,14.2,220,4700,female,2008 -Gentoo,Biscoe,50.7,15,223,5550,male,2008 -Gentoo,Biscoe,47.7,15,216,4750,female,2008 -Gentoo,Biscoe,46.4,15.6,221,5000,male,2008 -Gentoo,Biscoe,48.2,15.6,221,5100,male,2008 -Gentoo,Biscoe,46.5,14.8,217,5200,female,2008 -Gentoo,Biscoe,46.4,15,216,4700,female,2008 -Gentoo,Biscoe,48.6,16,230,5800,male,2008 -Gentoo,Biscoe,47.5,14.2,209,4600,female,2008 -Gentoo,Biscoe,51.1,16.3,220,6000,male,2008 -Gentoo,Biscoe,45.2,13.8,215,4750,female,2008 -Gentoo,Biscoe,45.2,16.4,223,5950,male,2008 -Gentoo,Biscoe,49.1,14.5,212,4625,female,2009 -Gentoo,Biscoe,52.5,15.6,221,5450,male,2009 -Gentoo,Biscoe,47.4,14.6,212,4725,female,2009 -Gentoo,Biscoe,50,15.9,224,5350,male,2009 -Gentoo,Biscoe,44.9,13.8,212,4750,female,2009 -Gentoo,Biscoe,50.8,17.3,228,5600,male,2009 -Gentoo,Biscoe,43.4,14.4,218,4600,female,2009 -Gentoo,Biscoe,51.3,14.2,218,5300,male,2009 -Gentoo,Biscoe,47.5,14,212,4875,female,2009 -Gentoo,Biscoe,52.1,17,230,5550,male,2009 -Gentoo,Biscoe,47.5,15,218,4950,female,2009 -Gentoo,Biscoe,52.2,17.1,228,5400,male,2009 -Gentoo,Biscoe,45.5,14.5,212,4750,female,2009 -Gentoo,Biscoe,49.5,16.1,224,5650,male,2009 -Gentoo,Biscoe,44.5,14.7,214,4850,female,2009 -Gentoo,Biscoe,50.8,15.7,226,5200,male,2009 -Gentoo,Biscoe,49.4,15.8,216,4925,male,2009 -Gentoo,Biscoe,46.9,14.6,222,4875,female,2009 -Gentoo,Biscoe,48.4,14.4,203,4625,female,2009 -Gentoo,Biscoe,51.1,16.5,225,5250,male,2009 -Gentoo,Biscoe,48.5,15,219,4850,female,2009 -Gentoo,Biscoe,55.9,17,228,5600,male,2009 -Gentoo,Biscoe,47.2,15.5,215,4975,female,2009 -Gentoo,Biscoe,49.1,15,228,5500,male,2009 -Gentoo,Biscoe,47.3,13.8,216,4725,NA,2009 -Gentoo,Biscoe,46.8,16.1,215,5500,male,2009 -Gentoo,Biscoe,41.7,14.7,210,4700,female,2009 -Gentoo,Biscoe,53.4,15.8,219,5500,male,2009 -Gentoo,Biscoe,43.3,14,208,4575,female,2009 -Gentoo,Biscoe,48.1,15.1,209,5500,male,2009 -Gentoo,Biscoe,50.5,15.2,216,5000,female,2009 -Gentoo,Biscoe,49.8,15.9,229,5950,male,2009 -Gentoo,Biscoe,43.5,15.2,213,4650,female,2009 -Gentoo,Biscoe,51.5,16.3,230,5500,male,2009 -Gentoo,Biscoe,46.2,14.1,217,4375,female,2009 -Gentoo,Biscoe,55.1,16,230,5850,male,2009 -Gentoo,Biscoe,44.5,15.7,217,4875,NA,2009 -Gentoo,Biscoe,48.8,16.2,222,6000,male,2009 -Gentoo,Biscoe,47.2,13.7,214,4925,female,2009 -Gentoo,Biscoe,NA,NA,NA,NA,NA,2009 -Gentoo,Biscoe,46.8,14.3,215,4850,female,2009 -Gentoo,Biscoe,50.4,15.7,222,5750,male,2009 -Gentoo,Biscoe,45.2,14.8,212,5200,female,2009 -Gentoo,Biscoe,49.9,16.1,213,5400,male,2009 -Chinstrap,Dream,46.5,17.9,192,3500,female,2007 -Chinstrap,Dream,50,19.5,196,3900,male,2007 -Chinstrap,Dream,51.3,19.2,193,3650,male,2007 -Chinstrap,Dream,45.4,18.7,188,3525,female,2007 -Chinstrap,Dream,52.7,19.8,197,3725,male,2007 -Chinstrap,Dream,45.2,17.8,198,3950,female,2007 -Chinstrap,Dream,46.1,18.2,178,3250,female,2007 -Chinstrap,Dream,51.3,18.2,197,3750,male,2007 -Chinstrap,Dream,46,18.9,195,4150,female,2007 -Chinstrap,Dream,51.3,19.9,198,3700,male,2007 -Chinstrap,Dream,46.6,17.8,193,3800,female,2007 -Chinstrap,Dream,51.7,20.3,194,3775,male,2007 -Chinstrap,Dream,47,17.3,185,3700,female,2007 -Chinstrap,Dream,52,18.1,201,4050,male,2007 -Chinstrap,Dream,45.9,17.1,190,3575,female,2007 -Chinstrap,Dream,50.5,19.6,201,4050,male,2007 -Chinstrap,Dream,50.3,20,197,3300,male,2007 -Chinstrap,Dream,58,17.8,181,3700,female,2007 -Chinstrap,Dream,46.4,18.6,190,3450,female,2007 -Chinstrap,Dream,49.2,18.2,195,4400,male,2007 -Chinstrap,Dream,42.4,17.3,181,3600,female,2007 -Chinstrap,Dream,48.5,17.5,191,3400,male,2007 -Chinstrap,Dream,43.2,16.6,187,2900,female,2007 -Chinstrap,Dream,50.6,19.4,193,3800,male,2007 -Chinstrap,Dream,46.7,17.9,195,3300,female,2007 -Chinstrap,Dream,52,19,197,4150,male,2007 -Chinstrap,Dream,50.5,18.4,200,3400,female,2008 -Chinstrap,Dream,49.5,19,200,3800,male,2008 -Chinstrap,Dream,46.4,17.8,191,3700,female,2008 -Chinstrap,Dream,52.8,20,205,4550,male,2008 -Chinstrap,Dream,40.9,16.6,187,3200,female,2008 -Chinstrap,Dream,54.2,20.8,201,4300,male,2008 -Chinstrap,Dream,42.5,16.7,187,3350,female,2008 -Chinstrap,Dream,51,18.8,203,4100,male,2008 -Chinstrap,Dream,49.7,18.6,195,3600,male,2008 -Chinstrap,Dream,47.5,16.8,199,3900,female,2008 -Chinstrap,Dream,47.6,18.3,195,3850,female,2008 -Chinstrap,Dream,52,20.7,210,4800,male,2008 -Chinstrap,Dream,46.9,16.6,192,2700,female,2008 -Chinstrap,Dream,53.5,19.9,205,4500,male,2008 -Chinstrap,Dream,49,19.5,210,3950,male,2008 -Chinstrap,Dream,46.2,17.5,187,3650,female,2008 -Chinstrap,Dream,50.9,19.1,196,3550,male,2008 -Chinstrap,Dream,45.5,17,196,3500,female,2008 -Chinstrap,Dream,50.9,17.9,196,3675,female,2009 -Chinstrap,Dream,50.8,18.5,201,4450,male,2009 -Chinstrap,Dream,50.1,17.9,190,3400,female,2009 -Chinstrap,Dream,49,19.6,212,4300,male,2009 -Chinstrap,Dream,51.5,18.7,187,3250,male,2009 -Chinstrap,Dream,49.8,17.3,198,3675,female,2009 -Chinstrap,Dream,48.1,16.4,199,3325,female,2009 -Chinstrap,Dream,51.4,19,201,3950,male,2009 -Chinstrap,Dream,45.7,17.3,193,3600,female,2009 -Chinstrap,Dream,50.7,19.7,203,4050,male,2009 -Chinstrap,Dream,42.5,17.3,187,3350,female,2009 -Chinstrap,Dream,52.2,18.8,197,3450,male,2009 -Chinstrap,Dream,45.2,16.6,191,3250,female,2009 -Chinstrap,Dream,49.3,19.9,203,4050,male,2009 -Chinstrap,Dream,50.2,18.8,202,3800,male,2009 -Chinstrap,Dream,45.6,19.4,194,3525,female,2009 -Chinstrap,Dream,51.9,19.5,206,3950,male,2009 -Chinstrap,Dream,46.8,16.5,189,3650,female,2009 -Chinstrap,Dream,45.7,17,195,3650,female,2009 -Chinstrap,Dream,55.8,19.8,207,4000,male,2009 -Chinstrap,Dream,43.5,18.1,202,3400,female,2009 -Chinstrap,Dream,49.6,18.2,193,3775,male,2009 -Chinstrap,Dream,50.8,19,210,4100,male,2009 -Chinstrap,Dream,50.2,18.7,198,3775,female,2009 diff --git a/apps/problem-sets/3-reactivity/3.1-reactive.calc/README b/apps/problem-sets/3-reactivity/3.1-reactive-calc/README similarity index 100% rename from apps/problem-sets/3-reactivity/3.1-reactive.calc/README rename to apps/problem-sets/3-reactivity/3.1-reactive-calc/README diff --git a/apps/problem-sets/3-reactivity/3.1-reactive.calc/app-solution.py b/apps/problem-sets/3-reactivity/3.1-reactive-calc/app-solution.py similarity index 100% rename from apps/problem-sets/3-reactivity/3.1-reactive.calc/app-solution.py rename to apps/problem-sets/3-reactivity/3.1-reactive-calc/app-solution.py diff --git a/apps/problem-sets/3-reactivity/3.1-reactive.calc/app.py b/apps/problem-sets/3-reactivity/3.1-reactive-calc/app.py similarity index 100% rename from apps/problem-sets/3-reactivity/3.1-reactive.calc/app.py rename to apps/problem-sets/3-reactivity/3.1-reactive-calc/app.py diff --git a/apps/problem-sets/3-reactivity/3.1-reactive.calc/data_import.py b/apps/problem-sets/3-reactivity/3.1-reactive-calc/data_import.py similarity index 100% rename from apps/problem-sets/3-reactivity/3.1-reactive.calc/data_import.py rename to apps/problem-sets/3-reactivity/3.1-reactive-calc/data_import.py diff --git a/apps/problem-sets/3-reactivity/3.1-reactive.calc/plots.py b/apps/problem-sets/3-reactivity/3.1-reactive-calc/plots.py similarity index 100% rename from apps/problem-sets/3-reactivity/3.1-reactive.calc/plots.py rename to apps/problem-sets/3-reactivity/3.1-reactive-calc/plots.py diff --git a/apps/problem-sets/3-reactivity/3.1-reactive.calc/simulated-data.csv b/apps/problem-sets/3-reactivity/3.1-reactive-calc/simulated-data.csv similarity index 100% rename from apps/problem-sets/3-reactivity/3.1-reactive.calc/simulated-data.csv rename to apps/problem-sets/3-reactivity/3.1-reactive-calc/simulated-data.csv diff --git a/apps/problem-sets/5-reactive-effects/5.1-reactive.event/README.md b/apps/problem-sets/5-reactive-effects/5.1-reactive-event/README.md similarity index 100% rename from apps/problem-sets/5-reactive-effects/5.1-reactive.event/README.md rename to apps/problem-sets/5-reactive-effects/5.1-reactive-event/README.md diff --git a/apps/problem-sets/5-reactive-effects/5.1-reactive.event/app-solution.py b/apps/problem-sets/5-reactive-effects/5.1-reactive-event/app-solution.py similarity index 100% rename from apps/problem-sets/5-reactive-effects/5.1-reactive.event/app-solution.py rename to apps/problem-sets/5-reactive-effects/5.1-reactive-event/app-solution.py diff --git a/apps/problem-sets/5-reactive-effects/5.1-reactive.event/app.py b/apps/problem-sets/5-reactive-effects/5.1-reactive-event/app.py similarity index 100% rename from apps/problem-sets/5-reactive-effects/5.1-reactive.event/app.py rename to apps/problem-sets/5-reactive-effects/5.1-reactive-event/app.py diff --git a/apps/problem-sets/5-reactive-effects/5.1-reactive.event/data_import.py b/apps/problem-sets/5-reactive-effects/5.1-reactive-event/data_import.py similarity index 100% rename from apps/problem-sets/5-reactive-effects/5.1-reactive.event/data_import.py rename to apps/problem-sets/5-reactive-effects/5.1-reactive-event/data_import.py diff --git a/apps/problem-sets/5-reactive-effects/5.1-reactive.event/plots.py b/apps/problem-sets/5-reactive-effects/5.1-reactive-event/plots.py similarity index 100% rename from apps/problem-sets/5-reactive-effects/5.1-reactive.event/plots.py rename to apps/problem-sets/5-reactive-effects/5.1-reactive-event/plots.py diff --git a/apps/problem-sets/5-reactive-effects/5.1-reactive.event/simulated-data.csv b/apps/problem-sets/5-reactive-effects/5.1-reactive-event/simulated-data.csv similarity index 100% rename from apps/problem-sets/5-reactive-effects/5.1-reactive.event/simulated-data.csv rename to apps/problem-sets/5-reactive-effects/5.1-reactive-event/simulated-data.csv diff --git a/apps/problem-sets/5-reactive-effects/5.2-reactive.effect/README.md b/apps/problem-sets/5-reactive-effects/5.2-reactive-effect/README.md similarity index 100% rename from apps/problem-sets/5-reactive-effects/5.2-reactive.effect/README.md rename to apps/problem-sets/5-reactive-effects/5.2-reactive-effect/README.md diff --git a/apps/problem-sets/5-reactive-effects/5.2-reactive.effect/app-solution.py b/apps/problem-sets/5-reactive-effects/5.2-reactive-effect/app-solution.py similarity index 100% rename from apps/problem-sets/5-reactive-effects/5.2-reactive.effect/app-solution.py rename to apps/problem-sets/5-reactive-effects/5.2-reactive-effect/app-solution.py diff --git a/apps/problem-sets/5-reactive-effects/5.2-reactive.effect/app.py b/apps/problem-sets/5-reactive-effects/5.2-reactive-effect/app.py similarity index 100% rename from apps/problem-sets/5-reactive-effects/5.2-reactive.effect/app.py rename to apps/problem-sets/5-reactive-effects/5.2-reactive-effect/app.py diff --git a/apps/problem-sets/5-reactive-effects/5.2-reactive.effect/data_import.py b/apps/problem-sets/5-reactive-effects/5.2-reactive-effect/data_import.py similarity index 100% rename from apps/problem-sets/5-reactive-effects/5.2-reactive.effect/data_import.py rename to apps/problem-sets/5-reactive-effects/5.2-reactive-effect/data_import.py diff --git a/apps/problem-sets/5-reactive-effects/5.2-reactive.effect/plots.py b/apps/problem-sets/5-reactive-effects/5.2-reactive-effect/plots.py similarity index 100% rename from apps/problem-sets/5-reactive-effects/5.2-reactive.effect/plots.py rename to apps/problem-sets/5-reactive-effects/5.2-reactive-effect/plots.py diff --git a/apps/problem-sets/5-reactive-effects/5.2-reactive.effect/simulated-data.csv b/apps/problem-sets/5-reactive-effects/5.2-reactive-effect/simulated-data.csv similarity index 100% rename from apps/problem-sets/5-reactive-effects/5.2-reactive.effect/simulated-data.csv rename to apps/problem-sets/5-reactive-effects/5.2-reactive-effect/simulated-data.csv diff --git a/exercises/2-basic-ui.qmd b/exercises/2-basic-ui.qmd new file mode 100644 index 0000000..e69de29 diff --git a/exercises/3-reactivity.qmd b/exercises/3-reactivity.qmd new file mode 100644 index 0000000..e69de29 diff --git a/exercises/4-dynamic-ui.qmd b/exercises/4-dynamic-ui.qmd new file mode 100644 index 0000000..e69de29 diff --git a/exercises/5-reactive-effect.qmd b/exercises/5-reactive-effect.qmd new file mode 100644 index 0000000..708dd43 --- /dev/null +++ b/exercises/5-reactive-effect.qmd @@ -0,0 +1,19 @@ +--- +title: "Basic UI" +--- + +```{python} +# | echo: false +import os + +os.chdir("..") +from helpers import problem_tabs + +``` + +```{python} +# | echo: false +# | output: asis + +problem_tabs("apps/problem-sets/5") +``` \ No newline at end of file From 63d5c4bb8f943a392de75a1ac54088755bd5f937 Mon Sep 17 00:00:00 2001 From: Gordon Shotwell Date: Thu, 4 Apr 2024 13:47:24 -0300 Subject: [PATCH 2/4] Add additional exercise pages --- _quarto.yml | 8 +++- .../1.0-hello-world/requirements.txt | 2 + .../1-getting-started/requirements.txt | 2 + .../2-basic-ui/2.1-sidebar/requirements.txt | 2 + .../2-basic-ui/2.2-cards/requirements.txt | 2 + .../2.3-cards-switch/requirements.txt | 2 + .../2.4-layout-columns/requirements.txt | 2 + apps/problem-sets/2-basic-ui/requirements.txt | 2 + .../3.1-reactive-calc/requirements.txt | 2 + .../{README.md => README} | 0 .../3.2-stacking-reactives/requirements.txt | 2 + .../3-reactivity/requirements.txt | 2 + .../4.1-render-express/{README.md => README} | 0 .../4.1-render-express/requirements.txt | 2 + .../4-dynamic-ui/requirements.txt | 2 + .../4.1-tabs/requirements.txt | 2 + .../4.2-cards/requirements.txt | 2 + .../4.3-layout/requirements.txt | 2 + .../4.4-ui-composition/requirements.txt | 2 + .../4.5-value-boxes/requirements.txt | 2 + .../4.6-dynamic-ui/requirements.txt | 2 + .../4.7-conditional-panel/requirements.txt | 2 + .../4-ui-customization/requirements.txt | 2 + .../5.1-reactive-event/{README.md => README} | 0 .../5.1-reactive-event/requirements.txt | 2 + .../5.2-reactive-effect/{README.md => README} | 0 .../5.2-reactive-effect/requirements.txt | 2 + .../5-reactive-effects/requirements.txt | 2 + apps/problem-sets/requirements.txt | 2 + exercises/1-hello-world.qmd | 16 ++++---- exercises/2-basic-ui.qmd | 40 +++++++++++++++++++ exercises/3-reactivity.qmd | 26 ++++++++++++ exercises/4-dynamic-ui.qmd | 19 +++++++++ exercises/5-reactive-effect.qmd | 12 +++++- helpers.py | 17 +++++++- 35 files changed, 174 insertions(+), 12 deletions(-) create mode 100644 apps/problem-sets/1-getting-started/1.0-hello-world/requirements.txt create mode 100644 apps/problem-sets/1-getting-started/requirements.txt create mode 100644 apps/problem-sets/2-basic-ui/2.1-sidebar/requirements.txt create mode 100644 apps/problem-sets/2-basic-ui/2.2-cards/requirements.txt create mode 100644 apps/problem-sets/2-basic-ui/2.3-cards-switch/requirements.txt create mode 100644 apps/problem-sets/2-basic-ui/2.4-layout-columns/requirements.txt create mode 100644 apps/problem-sets/2-basic-ui/requirements.txt create mode 100644 apps/problem-sets/3-reactivity/3.1-reactive-calc/requirements.txt rename apps/problem-sets/3-reactivity/3.2-stacking-reactives/{README.md => README} (100%) create mode 100644 apps/problem-sets/3-reactivity/3.2-stacking-reactives/requirements.txt create mode 100644 apps/problem-sets/3-reactivity/requirements.txt rename apps/problem-sets/4-dynamic-ui/4.1-render-express/{README.md => README} (100%) create mode 100644 apps/problem-sets/4-dynamic-ui/4.1-render-express/requirements.txt create mode 100644 apps/problem-sets/4-dynamic-ui/requirements.txt create mode 100644 apps/problem-sets/4-ui-customization/4.1-tabs/requirements.txt create mode 100644 apps/problem-sets/4-ui-customization/4.2-cards/requirements.txt create mode 100644 apps/problem-sets/4-ui-customization/4.3-layout/requirements.txt create mode 100644 apps/problem-sets/4-ui-customization/4.4-ui-composition/requirements.txt create mode 100644 apps/problem-sets/4-ui-customization/4.5-value-boxes/requirements.txt create mode 100644 apps/problem-sets/4-ui-customization/4.6-dynamic-ui/requirements.txt create mode 100644 apps/problem-sets/4-ui-customization/4.7-conditional-panel/requirements.txt create mode 100644 apps/problem-sets/4-ui-customization/requirements.txt rename apps/problem-sets/5-reactive-effects/5.1-reactive-event/{README.md => README} (100%) create mode 100644 apps/problem-sets/5-reactive-effects/5.1-reactive-event/requirements.txt rename apps/problem-sets/5-reactive-effects/5.2-reactive-effect/{README.md => README} (100%) create mode 100644 apps/problem-sets/5-reactive-effects/5.2-reactive-effect/requirements.txt create mode 100644 apps/problem-sets/5-reactive-effects/requirements.txt create mode 100644 apps/problem-sets/requirements.txt diff --git a/_quarto.yml b/_quarto.yml index ef2088a..a16492b 100644 --- a/_quarto.yml +++ b/_quarto.yml @@ -5,7 +5,13 @@ website: title: "Shiny for Python Workshop" sidebar: contents: - - exercises/1-hello-world.qmd + - section: "Exercises" + contents: + - exercises/1-hello-world.qmd + - exercises/2-basic-ui.qmd + - exercises/3-reactivity.qmd + - exercises/4-dynamic-ui.qmd + - exercises/5-reactive-effect.qmd navbar: tools: diff --git a/apps/problem-sets/1-getting-started/1.0-hello-world/requirements.txt b/apps/problem-sets/1-getting-started/1.0-hello-world/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/1-getting-started/1.0-hello-world/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/1-getting-started/requirements.txt b/apps/problem-sets/1-getting-started/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/1-getting-started/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/2-basic-ui/2.1-sidebar/requirements.txt b/apps/problem-sets/2-basic-ui/2.1-sidebar/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/2-basic-ui/2.1-sidebar/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/2-basic-ui/2.2-cards/requirements.txt b/apps/problem-sets/2-basic-ui/2.2-cards/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/2-basic-ui/2.2-cards/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/2-basic-ui/2.3-cards-switch/requirements.txt b/apps/problem-sets/2-basic-ui/2.3-cards-switch/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/2-basic-ui/2.3-cards-switch/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/2-basic-ui/2.4-layout-columns/requirements.txt b/apps/problem-sets/2-basic-ui/2.4-layout-columns/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/2-basic-ui/2.4-layout-columns/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/2-basic-ui/requirements.txt b/apps/problem-sets/2-basic-ui/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/2-basic-ui/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/3-reactivity/3.1-reactive-calc/requirements.txt b/apps/problem-sets/3-reactivity/3.1-reactive-calc/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/3-reactivity/3.1-reactive-calc/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/3-reactivity/3.2-stacking-reactives/README.md b/apps/problem-sets/3-reactivity/3.2-stacking-reactives/README similarity index 100% rename from apps/problem-sets/3-reactivity/3.2-stacking-reactives/README.md rename to apps/problem-sets/3-reactivity/3.2-stacking-reactives/README diff --git a/apps/problem-sets/3-reactivity/3.2-stacking-reactives/requirements.txt b/apps/problem-sets/3-reactivity/3.2-stacking-reactives/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/3-reactivity/3.2-stacking-reactives/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/3-reactivity/requirements.txt b/apps/problem-sets/3-reactivity/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/3-reactivity/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/4-dynamic-ui/4.1-render-express/README.md b/apps/problem-sets/4-dynamic-ui/4.1-render-express/README similarity index 100% rename from apps/problem-sets/4-dynamic-ui/4.1-render-express/README.md rename to apps/problem-sets/4-dynamic-ui/4.1-render-express/README diff --git a/apps/problem-sets/4-dynamic-ui/4.1-render-express/requirements.txt b/apps/problem-sets/4-dynamic-ui/4.1-render-express/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/4-dynamic-ui/4.1-render-express/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/4-dynamic-ui/requirements.txt b/apps/problem-sets/4-dynamic-ui/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/4-dynamic-ui/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/4-ui-customization/4.1-tabs/requirements.txt b/apps/problem-sets/4-ui-customization/4.1-tabs/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/4-ui-customization/4.1-tabs/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/4-ui-customization/4.2-cards/requirements.txt b/apps/problem-sets/4-ui-customization/4.2-cards/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/4-ui-customization/4.2-cards/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/4-ui-customization/4.3-layout/requirements.txt b/apps/problem-sets/4-ui-customization/4.3-layout/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/4-ui-customization/4.3-layout/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/4-ui-customization/4.4-ui-composition/requirements.txt b/apps/problem-sets/4-ui-customization/4.4-ui-composition/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/4-ui-customization/4.4-ui-composition/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/4-ui-customization/4.5-value-boxes/requirements.txt b/apps/problem-sets/4-ui-customization/4.5-value-boxes/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/4-ui-customization/4.5-value-boxes/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/4-ui-customization/4.6-dynamic-ui/requirements.txt b/apps/problem-sets/4-ui-customization/4.6-dynamic-ui/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/4-ui-customization/4.6-dynamic-ui/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/4-ui-customization/4.7-conditional-panel/requirements.txt b/apps/problem-sets/4-ui-customization/4.7-conditional-panel/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/4-ui-customization/4.7-conditional-panel/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/4-ui-customization/requirements.txt b/apps/problem-sets/4-ui-customization/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/4-ui-customization/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/5-reactive-effects/5.1-reactive-event/README.md b/apps/problem-sets/5-reactive-effects/5.1-reactive-event/README similarity index 100% rename from apps/problem-sets/5-reactive-effects/5.1-reactive-event/README.md rename to apps/problem-sets/5-reactive-effects/5.1-reactive-event/README diff --git a/apps/problem-sets/5-reactive-effects/5.1-reactive-event/requirements.txt b/apps/problem-sets/5-reactive-effects/5.1-reactive-event/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/5-reactive-effects/5.1-reactive-event/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/5-reactive-effects/5.2-reactive-effect/README.md b/apps/problem-sets/5-reactive-effects/5.2-reactive-effect/README similarity index 100% rename from apps/problem-sets/5-reactive-effects/5.2-reactive-effect/README.md rename to apps/problem-sets/5-reactive-effects/5.2-reactive-effect/README diff --git a/apps/problem-sets/5-reactive-effects/5.2-reactive-effect/requirements.txt b/apps/problem-sets/5-reactive-effects/5.2-reactive-effect/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/5-reactive-effects/5.2-reactive-effect/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/5-reactive-effects/requirements.txt b/apps/problem-sets/5-reactive-effects/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/5-reactive-effects/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/apps/problem-sets/requirements.txt b/apps/problem-sets/requirements.txt new file mode 100644 index 0000000..bfa2e59 --- /dev/null +++ b/apps/problem-sets/requirements.txt @@ -0,0 +1,2 @@ +pandas +plotly \ No newline at end of file diff --git a/exercises/1-hello-world.qmd b/exercises/1-hello-world.qmd index 394b05b..32b211e 100644 --- a/exercises/1-hello-world.qmd +++ b/exercises/1-hello-world.qmd @@ -17,7 +17,7 @@ from helpers import problem_tabs # | echo: false # | output: asis -problem_tabs("apps/problem-sets/1-getting-started/1.0-hello-world") +problem_tabs("1.0-hello-world") ``` @@ -25,47 +25,47 @@ problem_tabs("apps/problem-sets/1-getting-started/1.0-hello-world") # | echo: false # | output: asis -problem_tabs("apps/problem-sets/1-getting-started/1.1-data-frame") +problem_tabs("1.1-data-frame") ``` ```{python} # | echo: false # | output: asis -problem_tabs("apps/problem-sets/1-getting-started/1.2-debug") +problem_tabs("1.2-debug") ``` ```{python} # | echo: false # | output: asis -problem_tabs("apps/problem-sets/1-getting-started/1.3-filter-input") +problem_tabs("1.3-filter-input") ``` ```{python} # | echo: false # | output: asis -problem_tabs("apps/problem-sets/1-getting-started/1.4-filter-connect") +problem_tabs("1.4-filter-connect") ``` ```{python} # | echo: false # | output: asis -problem_tabs("apps/problem-sets/1-getting-started/1.5-debug") +problem_tabs("1.5-debug") ``` ```{python} # | echo: false # | output: asis -problem_tabs("apps/problem-sets/1-getting-started/1.6-debug") +problem_tabs("1.6-debug") ``` ```{python} # | echo: false # | output: asis -problem_tabs("apps/problem-sets/1-getting-started/1.7-add-plot") +problem_tabs("1.7-add-plot") ``` \ No newline at end of file diff --git a/exercises/2-basic-ui.qmd b/exercises/2-basic-ui.qmd index e69de29..dda725a 100644 --- a/exercises/2-basic-ui.qmd +++ b/exercises/2-basic-ui.qmd @@ -0,0 +1,40 @@ +--- +title: "Basic UI" +--- + +```{python} +# | echo: false +import os + +os.chdir("..") +from helpers import problem_tabs + +``` + +```{python} +# | echo: false +# | output: asis + +problem_tabs("2.1-sidebar") +``` + +```{python} +# | echo: false +# | output: asis + +problem_tabs("2.2-cards") +``` + +```{python} +# | echo: false +# | output: asis + +problem_tabs("2.3-cards-switch") +``` + +```{python} +# | echo: false +# | output: asis + +problem_tabs("2.4-layout-columns") +``` \ No newline at end of file diff --git a/exercises/3-reactivity.qmd b/exercises/3-reactivity.qmd index e69de29..06efcc8 100644 --- a/exercises/3-reactivity.qmd +++ b/exercises/3-reactivity.qmd @@ -0,0 +1,26 @@ +--- +title: "Reactivity" +--- + +```{python} +# | echo: false +import os + +os.chdir("..") +from helpers import problem_tabs + +``` + +```{python} +# | echo: false +# | output: asis + +problem_tabs("3.1-reactive-calc") +``` + +```{python} +# | echo: false +# | output: asis + +problem_tabs("3.2-stacking-reactives") +``` \ No newline at end of file diff --git a/exercises/4-dynamic-ui.qmd b/exercises/4-dynamic-ui.qmd index e69de29..7b9c39a 100644 --- a/exercises/4-dynamic-ui.qmd +++ b/exercises/4-dynamic-ui.qmd @@ -0,0 +1,19 @@ +--- +title: "Dynamic UI" +--- + +```{python} +# | echo: false +import os + +os.chdir("..") +from helpers import problem_tabs + +``` + +```{python} +# | echo: false +# | output: asis + +problem_tabs("4.1-render-express") +``` \ No newline at end of file diff --git a/exercises/5-reactive-effect.qmd b/exercises/5-reactive-effect.qmd index 708dd43..81205e6 100644 --- a/exercises/5-reactive-effect.qmd +++ b/exercises/5-reactive-effect.qmd @@ -1,5 +1,5 @@ --- -title: "Basic UI" +title: "Reactive Effects" --- ```{python} @@ -15,5 +15,13 @@ from helpers import problem_tabs # | echo: false # | output: asis -problem_tabs("apps/problem-sets/5") +problem_tabs("5.1-reactive-event") +``` + + +```{python} +# | echo: false +# | output: asis + +problem_tabs("5.2-reactive-effect") ``` \ No newline at end of file diff --git a/helpers.py b/helpers.py index 80fc1d8..b46a71f 100644 --- a/helpers.py +++ b/helpers.py @@ -108,7 +108,22 @@ def parse_readme(path: str) -> str: return file_contents -def problem_tabs(path: str) -> None: +def problem_tabs(folder_name: str) -> None: + + import os + + def find_problem_set_folder(base_path, target_path): + for root, dirs, files in os.walk(base_path): + for name in dirs: + full_path = os.path.join(root, name) + if target_path in full_path: + return full_path + raise FileNotFoundError( + f"Folder matching path '{target_path}' not found in '{base_path}'." + ) + + path = find_problem_set_folder("apps/problem-sets", folder_name) + block = QuartoPrint( [ "::::: {.column-screen-inset}", From 46ccdcd2876731fff9812fb5faf69d4c3c559ec8 Mon Sep 17 00:00:00 2001 From: Gordon Shotwell Date: Mon, 8 Apr 2024 13:31:55 -0300 Subject: [PATCH 3/4] Fix exercise bugs --- .../1-getting-started/1.1-data-frame/app.py | 1 + .../1-getting-started/1.3-filter-input/README | 3 +-- .../1-getting-started/1.4-filter-connect/app.py | 7 +++++-- .../1.7-add-plot/app-solution.py | 9 --------- .../3-reactivity/3.2-stacking-reactives/README | 2 +- .../3.2-stacking-reactives/app-solution.py | 2 +- .../3-reactivity/3.2-stacking-reactives/app.py | 16 +++++++++------- helpers.py | 3 +++ 8 files changed, 21 insertions(+), 22 deletions(-) diff --git a/apps/problem-sets/1-getting-started/1.1-data-frame/app.py b/apps/problem-sets/1-getting-started/1.1-data-frame/app.py index ec31ada..d09790b 100644 --- a/apps/problem-sets/1-getting-started/1.1-data-frame/app.py +++ b/apps/problem-sets/1-getting-started/1.1-data-frame/app.py @@ -4,6 +4,7 @@ infile = Path(__file__).parent / "simulated-data.csv" df = pd.read_csv(infile) +df = df.drop(columns=["text"]) @render.____ diff --git a/apps/problem-sets/1-getting-started/1.3-filter-input/README b/apps/problem-sets/1-getting-started/1.3-filter-input/README index ad0badf..61ddbf4 100644 --- a/apps/problem-sets/1-getting-started/1.3-filter-input/README +++ b/apps/problem-sets/1-getting-started/1.3-filter-input/README @@ -1,3 +1,2 @@ Add a select input to the app which lets the user select one of the accounts. For reference the account list is: -`["Berge & Berge", "Fritsch & Fritsch", "Hintz & Hintz", "Mosciski and Sons", "Wolff Ltd"` - ]` \ No newline at end of file +`["Berge & Berge", "Fritsch & Fritsch", "Hintz & Hintz", "Mosciski and Sons", "Wolff Ltd"]` \ No newline at end of file diff --git a/apps/problem-sets/1-getting-started/1.4-filter-connect/app.py b/apps/problem-sets/1-getting-started/1.4-filter-connect/app.py index ba1b0c7..94ef74f 100644 --- a/apps/problem-sets/1-getting-started/1.4-filter-connect/app.py +++ b/apps/problem-sets/1-getting-started/1.4-filter-connect/app.py @@ -1,4 +1,4 @@ -from shiny.express import render, ui +from shiny.express import render, ui, input import pandas as pd from pathlib import Path from data_import import df @@ -18,5 +18,8 @@ @render.data_frame def table(): - account_counts = df.groupby("sub_account").size().reset_index(name="counts") + account_subset = df + account_counts = ( + account_subset.groupby("sub_account").size().reset_index(name="counts") + ) return account_counts diff --git a/apps/problem-sets/1-getting-started/1.7-add-plot/app-solution.py b/apps/problem-sets/1-getting-started/1.7-add-plot/app-solution.py index ca40f6d..06681d9 100644 --- a/apps/problem-sets/1-getting-started/1.7-add-plot/app-solution.py +++ b/apps/problem-sets/1-getting-started/1.7-add-plot/app-solution.py @@ -16,15 +16,6 @@ ) -@render.data_frame -def table(): - account_subset = df[df["account"] == input.account()] - account_counts = ( - account_subset.groupby("sub_account").size().reset_index(name="counts") - ) - return account_counts - - @render_plotly def precision_recall_plot(): account_subset = df[df["account"] == input.account()] diff --git a/apps/problem-sets/3-reactivity/3.2-stacking-reactives/README b/apps/problem-sets/3-reactivity/3.2-stacking-reactives/README index db6aeb4..747e33f 100644 --- a/apps/problem-sets/3-reactivity/3.2-stacking-reactives/README +++ b/apps/problem-sets/3-reactivity/3.2-stacking-reactives/README @@ -1,5 +1,5 @@ We have a second sidebad input which allows the user to filter the dataset by the number of characters in the `text` field. Add a second reactive calculation to the app which filters the `account_data()` reactive. -For `input.chars()` returns a tuple with the lower and upper range of a value, and you can filter the data frame with: +For reference `input.chars()` returns a tuple with the lower and upper range of a value, and you can filter the data frame with: `df[df["text"].str.len().between(*input.chars()]`. diff --git a/apps/problem-sets/3-reactivity/3.2-stacking-reactives/app-solution.py b/apps/problem-sets/3-reactivity/3.2-stacking-reactives/app-solution.py index 317d293..1667929 100644 --- a/apps/problem-sets/3-reactivity/3.2-stacking-reactives/app-solution.py +++ b/apps/problem-sets/3-reactivity/3.2-stacking-reactives/app-solution.py @@ -12,7 +12,7 @@ def account_data(): @reactive.calc() def character_filter(): - return account_data()[(account_data()["text"].str.len().between(*input.chars()))] + return account_data()[account_data()["text"].str.len().between(*input.chars())] with ui.sidebar(): diff --git a/apps/problem-sets/3-reactivity/3.2-stacking-reactives/app.py b/apps/problem-sets/3-reactivity/3.2-stacking-reactives/app.py index de4ec2f..18dd1af 100644 --- a/apps/problem-sets/3-reactivity/3.2-stacking-reactives/app.py +++ b/apps/problem-sets/3-reactivity/3.2-stacking-reactives/app.py @@ -4,6 +4,12 @@ from plots import plot_auc_curve, plot_precision_recall_curve, plot_score_distribution from shinywidgets import render_plotly + +@reactive.calc +def account_data(): + return df[df["account"] == input.account()] + + with ui.sidebar(): ui.input_select( "account", @@ -32,14 +38,11 @@ @render_plotly def metric(): - account_subset = df[df["account"] == input.account()] if input.metric() == "ROC Curve": - return plot_auc_curve( - account_subset, "is_electronics", "training_score" - ) + return plot_auc_curve(account_data, "is_electronics", "training_score") else: return plot_precision_recall_curve( - account_subset, "is_electronics", "training_score" + account_data(), "is_electronics", "training_score" ) ui.input_select("metric", "Metric", choices=["ROC Curve", "Precision Recall"]) @@ -49,5 +52,4 @@ def metric(): @render_plotly def score_dist(): - account_subset = df[df["account"] == input.account()] - return plot_score_distribution(account_subset) + return plot_score_distribution(account_data()) diff --git a/helpers.py b/helpers.py index b46a71f..d088bff 100644 --- a/helpers.py +++ b/helpers.py @@ -124,8 +124,11 @@ def find_problem_set_folder(base_path, target_path): path = find_problem_set_folder("apps/problem-sets", folder_name) + formatted_title = "## " + folder_name.replace("-", " ").title() + block = QuartoPrint( [ + formatted_title, "::::: {.column-screen-inset}", "::: {.panel-tabset}", "## Goal", From f485182d054b453847d14f0b4f832c5740d65252 Mon Sep 17 00:00:00 2001 From: Gordon Shotwell Date: Tue, 9 Apr 2024 10:40:04 -0300 Subject: [PATCH 4/4] Trigger build --- exercises/1-hello-world.qmd | 1 - 1 file changed, 1 deletion(-) diff --git a/exercises/1-hello-world.qmd b/exercises/1-hello-world.qmd index 32b211e..711a123 100644 --- a/exercises/1-hello-world.qmd +++ b/exercises/1-hello-world.qmd @@ -11,7 +11,6 @@ from helpers import problem_tabs ``` -# Exercise 1.0 - Hello World ```{python} # | echo: false