✨ Added direct access to total death count and death rate by date
This commit is contained in:
parent
64d2950d59
commit
334f71e1b7
39
Analyser.py
39
Analyser.py
|
@ -106,7 +106,7 @@ class Analyser:
|
||||||
|
|
||||||
def getTotalCases(self, country, date=datetime.now().strftime('%Y-%m-%d')) -> int:
|
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 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
|
:param date: The date for which the case number is returned. Standard is the current date. Format YYYY-MM-DD
|
||||||
:return: The case number
|
:return: The case number
|
||||||
|
@ -174,6 +174,18 @@ class Analyser:
|
||||||
print('Unknown country')
|
print('Unknown country')
|
||||||
return '-1'
|
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:
|
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
|
Get a graph with the daily increase number of cases for the entered country
|
||||||
|
@ -205,3 +217,28 @@ class Analyser:
|
||||||
else:
|
else:
|
||||||
print('Unknown country')
|
print('Unknown country')
|
||||||
return '-1'
|
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)
|
||||||
|
|
1
Main.py
1
Main.py
|
@ -10,4 +10,5 @@ import UserInterface as UI
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
fetcher.updateStatsFile()
|
fetcher.updateStatsFile()
|
||||||
|
ana.Analyser().testGraph('Germany')
|
||||||
UI.main()
|
UI.main()
|
||||||
|
|
|
@ -112,8 +112,12 @@ class UserInterface(QWidget):
|
||||||
startDate = self.startDatePicker.currentText()
|
startDate = self.startDatePicker.currentText()
|
||||||
endDate = self.endDatePicker.currentText()
|
endDate = self.endDatePicker.currentText()
|
||||||
self.casesNumber.setText(
|
self.casesNumber.setText(
|
||||||
('<h4>Total case number in ' + country + ' as of ' + endDate + ': ' + str(self.analyser.getTotalCases(country,
|
('<h4>Statistics for ' + country
|
||||||
endDate))+'</h4>'))
|
+ ' as of ' + endDate + ': <font color="red">Total Cases:</font> '
|
||||||
|
+ str(self.analyser.getTotalCases(country,endDate))
|
||||||
|
+ ', <font color="red">Total Deaths:</font> ' + str(self.analyser.getTotalDeaths(country, endDate))
|
||||||
|
+ ', <font color="red">Death Rate:</font> ' + str(self.analyser.getDeathRate(country, endDate))[:4]
|
||||||
|
+ '%</h4>'))
|
||||||
casesGraphPath = self.analyser.getCasesGraph(country, startDate, endDate)
|
casesGraphPath = self.analyser.getCasesGraph(country, startDate, endDate)
|
||||||
caseIncreaseGraphPath = self.analyser.getCaseIncreaseGraph(country, startDate, endDate)
|
caseIncreaseGraphPath = self.analyser.getCaseIncreaseGraph(country, startDate, endDate)
|
||||||
deathGraphPath = self.analyser.getDeathGraph(country, startDate, endDate)
|
deathGraphPath = self.analyser.getDeathGraph(country, startDate, endDate)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user