✨ Added 7-Day-Mean to every plot
This commit is contained in:
parent
ac68c2389b
commit
cadda056fd
17
Analyser.py
17
Analyser.py
|
@ -66,11 +66,12 @@ class Analyser:
|
|||
countryData = self.df[self.df['countriesAndTerritories'].isin([country])]
|
||||
countryData = countryData.sort_values('dateRep')
|
||||
countryData['totalCases'] = countryData['cases'].cumsum()
|
||||
countryData['7-Day-Mean'] = countryData['totalCases'].rolling(7).mean()
|
||||
mask = (countryData['dateRep'] >= start_date) & (countryData['dateRep'] <= end_date)
|
||||
countryTimeData = countryData.loc[mask]
|
||||
|
||||
|
||||
countryTimeData.plot(ax=ax, x='dateRep', y='totalCases')
|
||||
countryTimeData.plot(ax=ax, x='dateRep', y='7-Day-Mean')
|
||||
|
||||
if showPlot:
|
||||
plt.show(block=True)
|
||||
|
@ -100,10 +101,13 @@ class Analyser:
|
|||
plt.title(('Daily new cases in ' + country))
|
||||
|
||||
countryData = self.df[self.df['countriesAndTerritories'].isin([country])]
|
||||
countryData = countryData.sort_values('dateRep')
|
||||
countryData['7-Day-Mean'] = countryData['cases'].rolling(7).mean()
|
||||
mask = (countryData['dateRep'] >= start_date) & (countryData['dateRep'] <= end_date)
|
||||
countryTimeData = countryData.loc[mask]
|
||||
|
||||
countryTimeData.plot(ax=ax, x='dateRep', y='cases')
|
||||
countryTimeData.plot(ax=ax, x='dateRep', y='7-Day-Mean')
|
||||
|
||||
if showPlot:
|
||||
plt.show(block=True)
|
||||
|
@ -147,11 +151,12 @@ class Analyser:
|
|||
countryData = self.df[self.df['countriesAndTerritories'].isin([country])]
|
||||
countryData = countryData.sort_values('dateRep')
|
||||
countryData['totalDeaths'] = countryData['deaths'].cumsum()
|
||||
countryData['7-Day-Mean'] = countryData['totalDeaths'].rolling(7).mean()
|
||||
mask = (countryData['dateRep'] >= start_date) & (countryData['dateRep'] <= end_date)
|
||||
countryTimeData = countryData.loc[mask]
|
||||
|
||||
|
||||
countryTimeData.plot(ax=ax, x='dateRep', y='totalDeaths')
|
||||
countryTimeData.plot(ax=ax, x='dateRep', y='7-Day-Mean')
|
||||
|
||||
if showPlot:
|
||||
plt.show(block=True)
|
||||
|
@ -181,10 +186,13 @@ class Analyser:
|
|||
plt.title(('Daily new deaths in ' + country))
|
||||
|
||||
countryData = self.df[self.df['countriesAndTerritories'].isin([country])]
|
||||
countryData = countryData.sort_values('dateRep')
|
||||
countryData['7-Day-Mean'] = countryData['deaths'].rolling(7).mean()
|
||||
mask = (countryData['dateRep'] >= start_date) & (countryData['dateRep'] <= end_date)
|
||||
countryTimeData = countryData.loc[mask]
|
||||
|
||||
countryTimeData.plot(ax=ax, x='dateRep', y='deaths')
|
||||
countryTimeData.plot(ax=ax, x='dateRep', y='7-Day-Mean')
|
||||
|
||||
if showPlot:
|
||||
plt.show(block=True)
|
||||
|
@ -230,11 +238,12 @@ class Analyser:
|
|||
countryData['totalCases'] = countryData['cases'].cumsum()
|
||||
countryData['totalDeaths'] = countryData['deaths'].cumsum()
|
||||
countryData['deathRate'] = countryData['totalDeaths'] / countryData['totalCases'] * 100
|
||||
countryData['7-Day-Mean'] = countryData['deathRate'].rolling(7).mean()
|
||||
mask = (countryData['dateRep'] >= start_date) & (countryData['dateRep'] <= end_date)
|
||||
countryTimeData = countryData.loc[mask]
|
||||
|
||||
|
||||
countryTimeData.plot(ax=ax, x='dateRep', y='deathRate')
|
||||
countryTimeData.plot(ax=ax, x='dateRep', y='7-Day-Mean')
|
||||
|
||||
if showPlot:
|
||||
plt.show(block=True)
|
||||
|
@ -303,10 +312,12 @@ class Analyser:
|
|||
countryData = countryData.sort_values('dateRep')
|
||||
countryData['totalCases'] = countryData['cases'].cumsum()
|
||||
countryData['increasePercentage'] = countryData['cases'] / countryData['totalCases'] * 100
|
||||
countryData['7-Day-Mean'] = countryData['increasePercentage'].rolling(7).mean()
|
||||
mask = (countryData['dateRep'] >= start_date) & (countryData['dateRep'] <= end_date)
|
||||
countryTimeData = countryData.loc[mask]
|
||||
|
||||
countryTimeData.plot(ax=ax, x='dateRep', y='increasePercentage')
|
||||
countryTimeData.plot(ax=ax, x='dateRep', y='7-Day-Mean')
|
||||
|
||||
if showPlot:
|
||||
plt.show(block=True)
|
||||
|
|
Loading…
Reference in New Issue
Block a user