PhiJoTo

7 Tages Impfdurchschnitt

May 5th, 2021
519
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import json
  2. import datetime
  3. import plotly.graph_objects as go
  4.  
  5. with open('./vaccine7dayGraph/vaccineData.json', encoding='utf-8-sig') as json_file:
  6.     data = json.loads(json_file.read())
  7.  
  8. dateDifferences = []
  9.  
  10. for day in data:
  11.     try:
  12.         doses = day["dosen_differenz_zum_vortag"]
  13.     except Exception as e:
  14.         doses = None
  15.         print(e)
  16.     if doses != None:
  17.         dateDifferences.append(doses)
  18.  
  19. dateDifferences.reverse()
  20.  
  21. weekly = []
  22.  
  23. for i in range(len(dateDifferences) // 7):
  24.     sevenDays = 0
  25.     sevenDays += int(dateDifferences[i * 7 + 0])
  26.     sevenDays += int(dateDifferences[i * 7 + 1])
  27.     sevenDays += int(dateDifferences[i * 7 + 2])
  28.     sevenDays += int(dateDifferences[i * 7 + 3])
  29.     sevenDays += int(dateDifferences[i * 7 + 4])
  30.     sevenDays += int(dateDifferences[i * 7 + 5])
  31.     sevenDays += int(dateDifferences[i * 7 + 6])
  32.     weekly.append(sevenDays / 7)
  33.  
  34. kalenderwochen = []
  35. for i in range(len(dateDifferences) // 7):
  36.     kalenderwochen.append(18 - i)
  37.  
  38. print(kalenderwochen)
  39. print(weekly)
  40.  
  41. fig = go.Figure()
  42. fig.add_trace(go.Scatter(x=kalenderwochen, y=weekly,
  43.                          line=dict(color='firebrick', width=4)))
  44.  
  45. fig.update_layout(title='7 Tage Impfdurchschnitt pro Woche',
  46.                   xaxis_title='Kalenderwoche',
  47.                   yaxis_title='Impfungen pro Woche')
  48. fig.show()
  49.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×