|
72 | 72 | "# Display the markdown text in rendered form\n",
|
73 | 73 | "display(Markdown(markdown_text))"
|
74 | 74 | ]
|
| 75 | + }, |
| 76 | + { |
| 77 | + "cell_type": "markdown", |
| 78 | + "id": "7101f2f7-2903-4cdc-b736-3f5000c467f7", |
| 79 | + "metadata": { |
| 80 | + "editable": true, |
| 81 | + "slideshow": { |
| 82 | + "slide_type": "" |
| 83 | + }, |
| 84 | + "tags": [] |
| 85 | + }, |
| 86 | + "source": [ |
| 87 | + "# Previous Workshops" |
| 88 | + ] |
| 89 | + }, |
| 90 | + { |
| 91 | + "cell_type": "code", |
| 92 | + "execution_count": 9, |
| 93 | + "id": "0a814add-f545-4663-8b06-39c40b636509", |
| 94 | + "metadata": { |
| 95 | + "editable": true, |
| 96 | + "slideshow": { |
| 97 | + "slide_type": "" |
| 98 | + }, |
| 99 | + "tags": [ |
| 100 | + "remove-input" |
| 101 | + ] |
| 102 | + }, |
| 103 | + "outputs": [ |
| 104 | + { |
| 105 | + "data": { |
| 106 | + "text/markdown": [ |
| 107 | + "<div align='center'>\n", |
| 108 | + "\n", |
| 109 | + "| Course Name | Course Info | Course Leader | Course Helpers | Course Developers |\n", |
| 110 | + "| --- | --- | --- | --- | --- |\n", |
| 111 | + "| Introduction to Python | 23rd/30th October 10am-1pm (online) | Tom Wilson | Liam Berrisford | Michael Saunby, Simon Kirby, Duncan McDougall, Eilis Hannon |\n", |
| 112 | + "\n", |
| 113 | + "</div>" |
| 114 | + ], |
| 115 | + "text/plain": [ |
| 116 | + "<IPython.core.display.Markdown object>" |
| 117 | + ] |
| 118 | + }, |
| 119 | + "metadata": {}, |
| 120 | + "output_type": "display_data" |
| 121 | + } |
| 122 | + ], |
| 123 | + "source": [ |
| 124 | + "import pandas as pd\n", |
| 125 | + "from IPython.display import display, HTML\n", |
| 126 | + "\n", |
| 127 | + "# Load the CSV file (adjust the file path as needed)\n", |
| 128 | + "file_path_previous = '../data/previous_workshops.csv'\n", |
| 129 | + "previous_courses_df = pd.read_csv(file_path_previous)\n", |
| 130 | + "\n", |
| 131 | + "# Strip any extra spaces in the column names\n", |
| 132 | + "previous_courses_df.columns = previous_courses_df.columns.str.strip()\n", |
| 133 | + "\n", |
| 134 | + "# Function to generate an HTML table row for each course\n", |
| 135 | + "def generate_html_row(row):\n", |
| 136 | + " return f\"<tr><td>{row['Course Name']}</td><td>{row['Course Info']}</td><td>{row['Course Leader']}</td><td>{row['Course Helpers']}</td><td>{row['Course Developers']}</td></tr>\"\n", |
| 137 | + "\n", |
| 138 | + "# Generate HTML table header\n", |
| 139 | + "html_table_header = \"\"\"\n", |
| 140 | + "<table style='width: 100%; text-align: center; border: 1px solid black; border-collapse: collapse;'>\n", |
| 141 | + "<tr>\n", |
| 142 | + "<th>Course Name</th>\n", |
| 143 | + "<th>Course Info</th>\n", |
| 144 | + "<th>Course Leader</th>\n", |
| 145 | + "<th>Course Helpers</th>\n", |
| 146 | + "<th>Course Developers</th>\n", |
| 147 | + "</tr>\n", |
| 148 | + "\"\"\"\n", |
| 149 | + "\n", |
| 150 | + "# Apply the function and create the HTML table rows\n", |
| 151 | + "table_rows = previous_courses_df.apply(generate_html_row, axis=1).tolist()\n", |
| 152 | + "\n", |
| 153 | + "# Join the table rows into a single block\n", |
| 154 | + "html_table = html_table_header + \"\\n\".join(table_rows) + \"</table>\"\n", |
| 155 | + "\n", |
| 156 | + "# Display the HTML table\n", |
| 157 | + "display(HTML(html_table))\n" |
| 158 | + ] |
| 159 | + }, |
| 160 | + { |
| 161 | + "cell_type": "code", |
| 162 | + "execution_count": null, |
| 163 | + "id": "2b3dc21f-a316-4357-8e4a-9c83c3703fd0", |
| 164 | + "metadata": { |
| 165 | + "editable": true, |
| 166 | + "slideshow": { |
| 167 | + "slide_type": "" |
| 168 | + }, |
| 169 | + "tags": [] |
| 170 | + }, |
| 171 | + "outputs": [], |
| 172 | + "source": [] |
75 | 173 | }
|
76 | 174 | ],
|
77 | 175 | "metadata": {
|
|
0 commit comments