Skip to content

Commit

Permalink
Create table of contents inside a details element
Browse files Browse the repository at this point in the history
  • Loading branch information
tomodwyer committed Feb 28, 2024
1 parent 6ffbfde commit 32bf55b
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions notebooks/diffable_python/SICBL_improvement_radar.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from pathlib import Path
import pandas as pd
import numpy as np
from IPython.display import Markdown, display
from IPython.display import Markdown, display, HTML
import matplotlib.pyplot as plt
from ebmdatalab import bq
import os
Expand Down Expand Up @@ -389,16 +389,12 @@ def apply_combined_filters(self):
display(Markdown(tool_summary))

# +
display(Markdown('## Table of Contents'))

measure_list = measure_list.sort_values(by='name') # sort by name
for m in measure_list['measure_name']:
measure_link = f"https://openprescribing.net/measure/{m}"
measure_description = measure_list.loc[measure_list["measure_name"] == m, "name"]
if len(measure_description) > 0:
measure_description=measure_description.iloc[0]

display(Markdown(f'<a href=#{m}>- {measure_description}</a>'))
measure_links = "".join([
f'<li><a href="#{m}">{measure_description.iloc[0]}</a></li>'
for m in measure_list['measure_name']
if (measure_description := measure_list.loc[measure_list["measure_name"] == m, "name"]).any()
])
display(HTML(f"<details><summary>Table of Contents</summary><ul>{measure_links}</ul></details>"))


for m in measure_list['measure_name']:
Expand Down

0 comments on commit 32bf55b

Please sign in to comment.