[docs]classSuriname(CountryTestBase):location:str="Suriname"units:str="tests performed"source_label:str="Directorate National Security"source_url:str="https://covid-19.sr/"source_url_ref:str="https://covid-19.sr/"
[docs]defread(self)->pd.DataFrame:"""Read data from source"""body=str(get_soup(self.source_url))# Get countcount=0if"Totaal Testen"inbody:count=int(body.split("Totaal Testen")[0].split('data-counter-value="')[-1].split('"')[0])# Get negative resultsnegative=0if"Totaal negatieve"inbody:negative=int(body.split("Totaal negatieve")[0].split('data-counter-value="')[-1].split('"')[0])df=pd.DataFrame({"Date":[localdate("America/Paramaribo")],"Daily change in cumulative total":[count],"positive":[count-negative],})returndf
[docs]defpipe_pr(self,df:pd.DataFrame)->pd.DataFrame:"""Calculate Positive Rate"""df["Positive rate"]=(df["positive"].rolling(7).sum().div(df["Daily change in cumulative total"].rolling(7).sum()).round(3)).fillna(0)returndf
[docs]defpipeline(self,df:pd.DataFrame)->pd.DataFrame:"""Pipeline for data processing"""return(df.pipe(self.pipe_metadata).pipe(self.pipe_merge_current).pipe(self.pipe_pr).drop_duplicates(subset=["Daily change in cumulative total","positive"],keep="first"))
[docs]defexport(self):"""Export data to csv"""df=self.read().pipe(self.pipeline)# self.export_datafile(df, float_format="%.5f")self.export_datafile(df,extra_cols=["positive"])