[docs]defpipe_vax_locations_to_html(df:pd.DataFrame)->pd.DataFrame:locale.setlocale(locale.LC_TIME,"en_US")# build tablecountry_faqs={"Israel","Palestine",}faq=' (see <a href="https://ourworldindata.org/covid-vaccinations#frequently-asked-questions">FAQ</a>)'codes=[iforiindf.iso_code.tolist()if"OWID_"notiniori=="OWID_KOS"]df=df.assign(location=(df.location.apply(lambdax:f"<td><strong>{x}</strong>{faqifxincountry_faqselse''}</td>")),source=('<td><a href="'+df.source_website+'">'+df.source_name+"</a></td>"),last_observation_date=(pd.to_datetime(df.last_observation_date).apply(lambdax:f"<td>{x.strftime('%b. %e, %Y')}</td>")),vaccines=(df.vaccines.apply(lambdax:f"<td>{x}</td>")),)[["location","source","last_observation_date","vaccines"]]df.columns=[col.capitalize().replace("_"," ")forcolindf.columns]body=("<tr>"+df.sum(axis=1)+"</tr>").sum(axis=0)header="<tr>"+"".join(f"<th>{col}</th>"forcolindf.columns)+"</tr>"html_table=f"<table><tbody>{header}{body}</tbody></table>"coverage_info=f"Vaccination against COVID-19 has now started in {len(codes)} locations."html_table=(f'<p><strong>{coverage_info}</strong></p><div class="tableContainer">{html_table}</div>\n').replace(" "," ")returnhtml_table
[docs]defgenerate_htmls():# Vaccinations html source tabledf=pd.read_csv(PATHS.DATA_VAX_META_FILE)html_table=pipe_vax_locations_to_html(df)withopen(PATHS.DATA_INTERNAL_VAX_TABLE,"w")asf:f.write(html_table)