Skip to content

Commit 918e955

Browse files
author
Gordon Shotwell
committed
Merge branch 'rebuild-website'
2 parents 985f7e5 + f485182 commit 918e955

File tree

9 files changed

+21
-23
lines changed

9 files changed

+21
-23
lines changed

apps/problem-sets/1-getting-started/1.1-data-frame/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
infile = Path(__file__).parent / "simulated-data.csv"
66
df = pd.read_csv(infile)
7+
df = df.drop(columns=["text"])
78

89

910
@render.____
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
Add a select input to the app which lets the user select one of the accounts. For reference the account list is:
2-
`["Berge & Berge", "Fritsch & Fritsch", "Hintz & Hintz", "Mosciski and Sons", "Wolff Ltd"`
3-
]`
2+
`["Berge & Berge", "Fritsch & Fritsch", "Hintz & Hintz", "Mosciski and Sons", "Wolff Ltd"]`

apps/problem-sets/1-getting-started/1.4-filter-connect/app.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from shiny.express import render, ui
1+
from shiny.express import render, ui, input
22
import pandas as pd
33
from pathlib import Path
44
from data_import import df
@@ -18,5 +18,8 @@
1818

1919
@render.data_frame
2020
def table():
21-
account_counts = df.groupby("sub_account").size().reset_index(name="counts")
21+
account_subset = df
22+
account_counts = (
23+
account_subset.groupby("sub_account").size().reset_index(name="counts")
24+
)
2225
return account_counts

apps/problem-sets/1-getting-started/1.7-add-plot/app-solution.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@
1616
)
1717

1818

19-
@render.data_frame
20-
def table():
21-
account_subset = df[df["account"] == input.account()]
22-
account_counts = (
23-
account_subset.groupby("sub_account").size().reset_index(name="counts")
24-
)
25-
return account_counts
26-
27-
2819
@render_plotly
2920
def precision_recall_plot():
3021
account_subset = df[df["account"] == input.account()]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
We have a second sidebad input which allows the user to filter the dataset by the number of characters in the `text` field.
22
Add a second reactive calculation to the app which filters the `account_data()` reactive.
33

4-
For `input.chars()` returns a tuple with the lower and upper range of a value, and you can filter the data frame with:
4+
For reference `input.chars()` returns a tuple with the lower and upper range of a value, and you can filter the data frame with:
55
`df[df["text"].str.len().between(*input.chars()]`.

apps/problem-sets/3-reactivity/3.2-stacking-reactives/app-solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def account_data():
1212

1313
@reactive.calc()
1414
def character_filter():
15-
return account_data()[(account_data()["text"].str.len().between(*input.chars()))]
15+
return account_data()[account_data()["text"].str.len().between(*input.chars())]
1616

1717

1818
with ui.sidebar():

apps/problem-sets/3-reactivity/3.2-stacking-reactives/app.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
from plots import plot_auc_curve, plot_precision_recall_curve, plot_score_distribution
55
from shinywidgets import render_plotly
66

7+
8+
@reactive.calc
9+
def account_data():
10+
return df[df["account"] == input.account()]
11+
12+
713
with ui.sidebar():
814
ui.input_select(
915
"account",
@@ -32,14 +38,11 @@
3238

3339
@render_plotly
3440
def metric():
35-
account_subset = df[df["account"] == input.account()]
3641
if input.metric() == "ROC Curve":
37-
return plot_auc_curve(
38-
account_subset, "is_electronics", "training_score"
39-
)
42+
return plot_auc_curve(account_data, "is_electronics", "training_score")
4043
else:
4144
return plot_precision_recall_curve(
42-
account_subset, "is_electronics", "training_score"
45+
account_data(), "is_electronics", "training_score"
4346
)
4447

4548
ui.input_select("metric", "Metric", choices=["ROC Curve", "Precision Recall"])
@@ -49,5 +52,4 @@ def metric():
4952

5053
@render_plotly
5154
def score_dist():
52-
account_subset = df[df["account"] == input.account()]
53-
return plot_score_distribution(account_subset)
55+
return plot_score_distribution(account_data())

exercises/1-hello-world.qmd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ from helpers import problem_tabs
1111
1212
```
1313

14-
# Exercise 1.0 - Hello World
1514

1615
```{python}
1716
# | echo: false

helpers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@ def find_problem_set_folder(base_path, target_path):
124124

125125
path = find_problem_set_folder("apps/problem-sets", folder_name)
126126

127+
formatted_title = "## " + folder_name.replace("-", " ").title()
128+
127129
block = QuartoPrint(
128130
[
131+
formatted_title,
129132
"::::: {.column-screen-inset}",
130133
"::: {.panel-tabset}",
131134
"## Goal",

0 commit comments

Comments
 (0)