diff --git a/Analyser.py b/Analyser.py index da9656c..21b425c 100644 --- a/Analyser.py +++ b/Analyser.py @@ -106,7 +106,7 @@ class Analyser: def getTotalCases(self, country, date=datetime.now().strftime('%Y-%m-%d')) -> int: """ - Get the current total cases for the entered country + Get the total cases for the entered country and date :param country: The country you want the case number for. Access available countries via getAvailableCountries() :param date: The date for which the case number is returned. Standard is the current date. Format YYYY-MM-DD :return: The case number @@ -174,6 +174,18 @@ class Analyser: print('Unknown country') return '-1' + def getTotalDeaths(self, country, date=datetime.now().strftime('%Y-%m-%d')) -> int: + """ + Get the total deaths for the entered country and date + :param country: The country you want the case number for. Access available countries via getAvailableCountries() + :param date: The date for which the case number is returned. Standard is the current date. Format YYYY-MM-DD + :return: The case number + """ + countryData = self.df[self.df['countriesAndTerritories'].isin([country])] + mask = (countryData['dateRep'] <= date) + countryTimeData = countryData.loc[mask] + return countryTimeData['deaths'].sum() + def getDailyDeathRateGraph(self, country, start_date='2019-12-31', end_date=datetime.now().strftime('%Y-%m-%d')) -> str: """ Get a graph with the daily increase number of cases for the entered country @@ -204,4 +216,29 @@ class Analyser: return filePath else: print('Unknown country') - return '-1' \ No newline at end of file + return '-1' + + def getDeathRate(self, country, date=datetime.now().strftime('%Y-%m-%d')) -> int: + """ + Get the death rate for the entered country and date + :param country: The country you want the case number for. Access available countries via getAvailableCountries() + :param date: The date for which the case number is returned. Standard is the current date. Format YYYY-MM-DD + :return: The case number + """ + countryData = self.df[self.df['countriesAndTerritories'].isin([country])] + mask = (countryData['dateRep'] <= date) + countryTimeData = countryData.loc[mask] + return (countryTimeData['deaths'].sum()/countryTimeData['cases'].sum()*100) + + def testGraph(self, country, start_date='2019-12-31', end_date=datetime.now().strftime('%Y-%m-%d')) -> str: + countryData = self.df[self.df['countriesAndTerritories'].isin([country])] + mask = (countryData['dateRep'] >= start_date) & (countryData['dateRep'] <= end_date) + countryTimeData = countryData.loc[mask] + countryTimeData = countryTimeData.sort_values('dateRep') + countryTimeData['totalCases'] = countryTimeData['cases'].cumsum() + countryTimeData['totalDeaths'] = countryTimeData['deaths'].cumsum() + countryTimeData['deathRate'] = countryTimeData['totalDeaths'] / countryTimeData['totalCases'] * 100 + + countryTimeData.plot.scatter(x='totalCases', y='cases', c='deaths') + + plt.show(block=True) diff --git a/Main.py b/Main.py index 26025e0..d71d2df 100644 --- a/Main.py +++ b/Main.py @@ -10,4 +10,5 @@ import UserInterface as UI if __name__ == '__main__': fetcher.updateStatsFile() + ana.Analyser().testGraph('Germany') UI.main() diff --git a/UserInterface.py b/UserInterface.py index 334ee00..2cbf1d3 100644 --- a/UserInterface.py +++ b/UserInterface.py @@ -112,8 +112,12 @@ class UserInterface(QWidget): startDate = self.startDatePicker.currentText() endDate = self.endDatePicker.currentText() self.casesNumber.setText( - ('