# -*- coding: utf-8 -*- """ Project: Analyse worldwide COVID-19 Data and provide graphs etc. @author Patrick Müller """ import numpy as np import pandas as pd import matplotlib.pyplot as plt import tkinter as tk """ Fields in csv: dateRep day month year cases deaths countriesAndTerritories geoId countryterritoryCode popData2018 """ from datetime import datetime, timedelta class Analyser: # Pandas Settings pd.set_option('display.max_row', 50) pd.set_option('display.max_column', 10) df = pd.read_csv('2020-03-28_11-00.csv', encoding='windows-1252') df['dateRep'] = pd.to_datetime(df['dateRep']) print(df['dateRep'].head()) def getAvailableCountries(self): return self.df['countriesAndTerritories'].unique() def getCasesGraph(self, country) -> str: """ Get a graph with the absolute number of cases by day for the entered country :param country: The country you wish to get the graph for :return: The path for the picture of the graph """ fig = plt.figure() ax = fig.add_subplot(111) countryData = self.df[self.df['countriesAndTerritories'].isin([country])] print(countryData['cases'].sum()) return 'abc' def getTotalCases(self, country, date=datetime.now().strftime('%Y-%m-%d')) -> int: """ Get the current total cases for the entered country :param country: The country you want the case number for :param date: The date for which the case number is returned. Standard is the current date. :return: The case number """ countryData = self.df[self.df['countriesAndTerritories'].isin([country])] finalData = pd.DataFrame countryData.filter(datetime.strptime(country)) print(finalData) return countryData['cases'].sum()