Skip to content

Commit 322ad0f

Browse files
Merge pull request #259 from coding-for-reproducible-research/Table_For_Sign_Up
COnvert list into table for course overview page
2 parents 51c86cc + 75df33d commit 322ad0f

File tree

2 files changed

+93
-53
lines changed

2 files changed

+93
-53
lines changed

cfrr_program_details/courses_overview.ipynb

Lines changed: 74 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
{
1212
"cell_type": "code",
13-
"execution_count": 1,
13+
"execution_count": 10,
1414
"id": "d3aa7606-0f50-4f05-b104-ad4521c80406",
1515
"metadata": {
1616
"editable": true,
@@ -24,21 +24,24 @@
2424
"outputs": [
2525
{
2626
"data": {
27-
"text/markdown": [
28-
"- Regression Analysis in R: Adapting to Varied Data Types: 13th January 2025 1-4pm (Online only) - [MS Form Sign-up](https://forms.office.com/e/QK4qbskQKe)\n",
29-
"- Introduction to Python: 17th/24th January 2025 10am-1pm (In-person only) - [MS Form Sign-up](https://forms.office.com/e/YAxvuE5dG5)\n",
30-
"- Computational Thinking: 28th January/4th February 2025 10am-1pm (In-person only) - [MS Form Sign-up](https://forms.office.com/e/HBxtMLxRZr)\n",
31-
"- Introduction to Unix: 5th/12th February 2025 1-4pm (Penryn Campus only) - [MS Form Sign-up](https://forms.office.com/e/6nrfXabJSH)\n",
32-
"- Python for Data Analysis: 6th/13th February 2025 1-4pm (Online only) - [MS Form Sign-up](https://forms.office.com/e/rJRBxYnxKA)\n",
33-
"- Introduction to R: 25th February/4th March/11th March 2025 10am-1pm (In-person only) - [MS Form Sign-up](https://forms.office.com/e/3BUKkXNELt)\n",
34-
"- Introduction to Version Control: 28th February/7th March 2025 10am-1pm (Online only) - [MS Form Sign-up](https://forms.office.com/e/YCB5kkGrws)\n",
35-
"- Introduction to Machine Learning: 14th/21st March 2025 10am-1pm (In-person only) - Registration Will Be Available Soon\n",
36-
"- Intermediate Version Control: 17th/24th March 2025 1-4pm (Online only) - Registration Will Be Available Soon\n",
37-
"- Introduction to HPC: 21st/28th March 2025 1.15-4.15pm (In-person only) - Registration Will Be Available Soon\n",
38-
"- Introduction to Regression with R: 28th March 2025 10am-1pm (In-person only) - Registration Will Be Available Soon"
27+
"text/html": [
28+
"\n",
29+
"<table style=\"width:100%; text-align:center; border:1px solid black; border-collapse:collapse;\">\n",
30+
" <tr style=\"background:#f2f2f2;\">\n",
31+
" <th>Course Name</th>\n",
32+
" <th>Course Dates</th>\n",
33+
" <th>Location</th>\n",
34+
" <th>Registration Link</th>\n",
35+
" </tr>\n",
36+
"<tr><td style='padding:8px'><a href=\"../programme_information/intro_to_julia.ipynb\" target=\"_blank\">Introduction to Julia</a></td><td style='padding:8px'>2nd/9th/16th June 2025 1-4pm</td><td style='padding:8px'>Online only</td><td style='padding:8px'><a href=\"https://forms.office.com/e/QBS4nXp3Pz\" target=\"_blank\">Sign-Up</a></td></tr>\n",
37+
"<tr><td style='padding:8px'><a href=\"../programme_information/intro_to_hpc.ipynb\" target=\"_blank\">Introduction to HPC</a></td><td style='padding:8px'>4th/11th June 2025 1-4pm</td><td style='padding:8px'>In-person only</td><td style='padding:8px'><a href=\"https://forms.office.com/e/fKPjWbddYf\" target=\"_blank\">Sign-Up</a></td></tr>\n",
38+
"<tr><td style='padding:8px'><a href=\"../programme_information/Introduction_to_Markdown_in_R.ipynb\" target=\"_blank\">Introduction to Markdown in R</a></td><td style='padding:8px'>6th June 2025 10am-1pm</td><td style='padding:8px'>In-person only</td><td style='padding:8px'><a href=\"https://forms.office.com/e/8diVktHHzt\" target=\"_blank\">Sign-Up</a></td></tr>\n",
39+
"<tr><td style='padding:8px'>Using Markdown for Python</td><td style='padding:8px'>10th June 2025 10am-1pm</td><td style='padding:8px'>In-person only</td><td style='padding:8px'><a href=\"https://forms.office.com/e/5ixSXnxdHb\" target=\"_blank\">Sign-Up</a></td></tr>\n",
40+
"<tr><td style='padding:8px'><a href=\"../programme_information/parallel_computing.ipynb\" target=\"_blank\">Parallel Computing</a></td><td style='padding:8px'>12th/19th June 2025 10am-1pm</td><td style='padding:8px'>Online only</td><td style='padding:8px'><a href=\"https://forms.office.com/e/pEk26HmbAe\" target=\"_blank\">Sign-Up</a></td></tr>\n",
41+
"</table>"
3942
],
4043
"text/plain": [
41-
"<IPython.core.display.Markdown object>"
44+
"<IPython.core.display.HTML object>"
4245
]
4346
},
4447
"metadata": {},
@@ -47,7 +50,7 @@
4750
],
4851
"source": [
4952
"import pandas as pd\n",
50-
"from IPython.display import Markdown, display\n",
53+
"from IPython.display import display, HTML\n",
5154
"from datetime import datetime\n",
5255
"\n",
5356
"# Load the CSV file (adjust the file path as needed)\n",
@@ -57,35 +60,72 @@
5760
"# Strip any extra spaces in the column names\n",
5861
"courses_df.columns = courses_df.columns.str.strip()\n",
5962
"\n",
60-
"# Convert the 'End Date' column to datetime (assuming the date format is day-first)\n",
61-
"courses_df['End Date'] = pd.to_datetime(courses_df['End Date'], dayfirst=True, errors='coerce')\n",
63+
"# Parse dates (assuming day-first)\n",
64+
"courses_df['End Date'] = pd.to_datetime(courses_df['End Date'], dayfirst=True, errors='coerce')\n",
6265
"courses_df['Start Date'] = pd.to_datetime(courses_df['Start Date'], dayfirst=True, errors='coerce')\n",
6366
"\n",
64-
"# Get today's date\n",
6567
"today = datetime.now()\n",
6668
"\n",
67-
"# Filter for rows that contain valid MS Form Signup links, Course Date information, and check if the 'End Date' is still valid\n",
68-
"filtered_courses_df = courses_df.dropna(subset=['Course Date'])\n",
69-
"filtered_courses_df = filtered_courses_df[filtered_courses_df['End Date'] > today]\n",
70-
"filtered_courses_df = filtered_courses_df[filtered_courses_df['Start Date'] <= today]\n",
71-
"filtered_courses_df = filtered_courses_df.sort_values(by=\"End Date\")\n",
69+
"# Filter to “in-progress or upcoming” courses with valid Course Date\n",
70+
"mask_dates = courses_df['Course Date'].notna()\n",
71+
"mask_started = courses_df['Start Date'] <= today\n",
72+
"mask_not_ended = courses_df['End Date'] > today\n",
73+
"\n",
74+
"upcoming = (\n",
75+
" courses_df[mask_dates & mask_started & mask_not_ended]\n",
76+
" .sort_values('End Date')\n",
77+
" .reset_index(drop=True)\n",
78+
")\n",
79+
"\n",
80+
"# Build the HTML table header\n",
81+
"html_header = \"\"\"\n",
82+
"<table style=\"width:100%; text-align:center; border:1px solid black; border-collapse:collapse;\">\n",
83+
" <tr style=\"background:#f2f2f2;\">\n",
84+
" <th>Course Name</th>\n",
85+
" <th>Course Dates</th>\n",
86+
" <th>Location</th>\n",
87+
" <th>Registration Link</th>\n",
88+
" </tr>\n",
89+
"\"\"\"\n",
90+
"\n",
91+
"def generate_row(row):\n",
92+
" # Wrap Course Name in a link to the Homepage Filepath\n",
93+
" name = row['Course Name']\n",
94+
" page_url = row.get('Homepage Filepath', '')\n",
95+
" if pd.notna(page_url) and str(page_url).strip():\n",
96+
" name_html = f'<a href=\"{page_url}\" target=\"_blank\">{name}</a>'\n",
97+
" else:\n",
98+
" name_html = name\n",
7299
"\n",
73-
"# Function to generate markdown text based on course details\n",
74-
"def generate_markdown(row):\n",
75-
" if pd.isna(row['MS Form Signup']) or not row['MS Form Signup'].strip():\n",
76-
" return f\"- {row['Course Name']}: {row['Course Date']} - Registration Will Be Available Soon\"\n",
100+
" # Dates and location\n",
101+
" dates = row['Course Date']\n",
102+
" location = row.get('Location', '')\n",
103+
"\n",
104+
" # Registration link\n",
105+
" signup = row.get('MS Form Signup', '')\n",
106+
" if pd.isna(signup) or not str(signup).strip():\n",
107+
" link_html = \"Registration Will Be Available Soon\"\n",
77108
" else:\n",
78-
" return f\"- {row['Course Name']}: {row['Course Date']} - [MS Form Sign-up]({row['MS Form Signup']})\"\n",
109+
" link_html = f'<a href=\"{signup}\" target=\"_blank\">Sign-Up</a>'\n",
110+
"\n",
111+
" return (\n",
112+
" \"<tr>\"\n",
113+
" f\"<td style='padding:8px'>{name_html}</td>\"\n",
114+
" f\"<td style='padding:8px'>{dates}</td>\"\n",
115+
" f\"<td style='padding:8px'>{location}</td>\"\n",
116+
" f\"<td style='padding:8px'>{link_html}</td>\"\n",
117+
" \"</tr>\"\n",
118+
" )\n",
79119
"\n",
80120
"\n",
81-
"# Apply the function and create the markdown output\n",
82-
"markdown_output = filtered_courses_df.apply(generate_markdown, axis=1).tolist()\n",
121+
"# Generate all rows\n",
122+
"rows_html = \"\\n\".join(upcoming.apply(generate_row, axis=1).tolist())\n",
83123
"\n",
84-
"# Join the markdown lines into a single block\n",
85-
"markdown_text = \"\\n\".join(markdown_output)\n",
124+
"# Close the table\n",
125+
"html_table = html_header + rows_html + \"\\n</table>\"\n",
86126
"\n",
87-
"# Display the markdown text in rendered form\n",
88-
"display(Markdown(markdown_text))"
127+
"# Display it\n",
128+
"display(HTML(html_table))\n"
89129
]
90130
},
91131
{

data/workshop_info.csv

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
Course Name,Start Date,End Date ,Course Date,MS Form Signup
2-
Introduction to Python,19/02/2025,06/05/2025,13th/20th May 2025 1-4pm (In-person at St. Luke's Campus only),https://forms.office.com/e/ExETz2Hzt1
3-
Python for Data Analysis,,,,
4-
Introduction to R,17/02/2025,07/05/2025,14th/21st/28th May 2025 1-4pm (In-person at Penryn Campus only),https://forms.office.com/e/crqiaNABbd
5-
Introduction to Regression with R,03/12/2024,22/03/2025,28th March 2025 10am-1pm (In-person only),https://forms.office.com/e/fEFmiN1GyE
6-
Regression Analysis in R: Adapting to Varied Data Types,,,,
7-
Working with Data in R,05/02/2025,24/03/2025,1st/8th April 2025 10am-1pm (In-person only),https://forms.office.com/e/922VUNiQQN
8-
Introduction to HPC,19/02/2025,28/05/2025,4th/11th June 2025 1-4pm (In-person only),https://forms.office.com/e/fKPjWbddYf
9-
Introduction to Version Control,19/02/2025,06/05/2025,13th/20th May 2025 10am-1pm (In-person only),https://forms.office.com/e/iyecXdreu0
10-
Intermediate Version Control,03/12/2024,11/03/2025,17th/24th March 2025 1-4pm (Online only),https://forms.office.com/e/zFdFmS8mUi
11-
Introduction to Unix,,,,
12-
Computational Thinking,,,,
13-
Software Development Best Practice,,,,
14-
Introduction to Julia,19/02/2025,26/05/2025,2nd/9th/16th June 2025 1-4pm (Online only),https://forms.office.com/e/QBS4nXp3Pz
15-
Parallel Computing,19/02/2025,05/06/2025,12th/19th June 2025 10am-1pm (Online only),https://forms.office.com/e/pEk26HmbAe
16-
Introduction to Machine Learning,03/12/2024,27/02/2025,7th/14th/21st March 2025 10am-1pm (In-person only),https://forms.office.com/e/rrkTddEa4j
17-
Improve your R Code,19/02/2025,22/04/2025,29th April 2025 10am-1pm (In-person only),https://forms.office.com/e/bUXinqvWja
18-
Introduction to Markdown in R,19/02/2025,30/05/2025,6th June 2025 10am-1pm (In-person only),https://forms.office.com/e/8diVktHHzt
19-
Using Markdown for Python,19/02/2025,03/06/2025,10th June 2025 10am-1pm (In-person only),https://forms.office.com/e/5ixSXnxdHb
1+
Course Name,Start Date,End Date ,Course Date,MS Form Signup,Location,Homepage Filepath
2+
Introduction to Python,19/02/2025,06/05/2025,13th/20th May 2025 1-4pm,https://forms.office.com/e/ExETz2Hzt1,In-person at St. Luke's Campus only,https://coding-for-reproducible-research.github.io/CfRR_Courses/programme_information/intro_to_python.html
3+
Python for Data Analysis,,,,,,
4+
Introduction to R,17/02/2025,07/05/2025,14th/21st/28th May 2025 1-4pm,https://forms.office.com/e/crqiaNABbd,In-person at Penryn Campus only,https://coding-for-reproducible-research.github.io/CfRR_Courses/programme_information/intro_to_r.html
5+
Introduction to Regression with R,03/12/2024,22/03/2025,28th March 2025 10am-1pm,https://forms.office.com/e/fEFmiN1GyE,In-person only,https://coding-for-reproducible-research.github.io/CfRR_Courses/programme_information/intro_regression_analysis_with_r.html
6+
Regression Analysis in R: Adapting to Varied Data Types,,,,,,
7+
Working with Data in R,05/02/2025,24/03/2025,1st/8th April 2025 10am-1pm,https://forms.office.com/e/922VUNiQQN,In-person only,https://coding-for-reproducible-research.github.io/CfRR_Courses/programme_information/working_with_data_in_r.html
8+
Introduction to HPC,19/02/2025,28/05/2025,4th/11th June 2025 1-4pm,https://forms.office.com/e/fKPjWbddYf,In-person only,https://coding-for-reproducible-research.github.io/CfRR_Courses/programme_information/intro_to_hpc.html
9+
Introduction to Version Control,19/02/2025,06/05/2025,13th/20th May 2025 10am-1pm,https://forms.office.com/e/iyecXdreu0,In-person only,https://coding-for-reproducible-research.github.io/CfRR_Courses/programme_information/intro_to_version_control.html
10+
Intermediate Version Control,03/12/2024,11/03/2025,17th/24th March 2025 1-4pm,https://forms.office.com/e/zFdFmS8mUi,Online only,https://coding-for-reproducible-research.github.io/CfRR_Courses/programme_information/intermediate_version_control.html
11+
Introduction to Unix,,,,,,
12+
Computational Thinking,,,,,,
13+
Software Development Best Practice,,,,,,
14+
Introduction to Julia,19/02/2025,26/05/2025,2nd/9th/16th June 2025 1-4pm,https://forms.office.com/e/QBS4nXp3Pz,Online only,https://coding-for-reproducible-research.github.io/CfRR_Courses/programme_information/intro_to_julia.html
15+
Parallel Computing,19/02/2025,05/06/2025,12th/19th June 2025 10am-1pm,https://forms.office.com/e/pEk26HmbAe,Online only,https://coding-for-reproducible-research.github.io/CfRR_Courses/programme_information/parallel_computing.html
16+
Introduction to Machine Learning,03/12/2024,27/02/2025,7th/14th/21st March 2025 10am-1pm,https://forms.office.com/e/rrkTddEa4j,In-person only,https://coding-for-reproducible-research.github.io/CfRR_Courses/programme_information/introduction_to_machine_learning.html
17+
Improve your R Code,19/02/2025,22/04/2025,29th April 2025 10am-1pm,https://forms.office.com/e/bUXinqvWja,In-person only,https://coding-for-reproducible-research.github.io/CfRR_Courses/programme_information/improve_your_r_code.html
18+
Introduction to Markdown in R,19/02/2025,30/05/2025,6th June 2025 10am-1pm,https://forms.office.com/e/8diVktHHzt,In-person only,https://coding-for-reproducible-research.github.io/CfRR_Courses/programme_information/Introduction_to_Markdown_in_R.html
19+
Using Markdown for Python,19/02/2025,03/06/2025,10th June 2025 10am-1pm,https://forms.office.com/e/5ixSXnxdHb,In-person only,

0 commit comments

Comments
 (0)