Esempio n. 1
0
	def __init__(self, name):
		super().__init__(name)

		self.ttype = 'country'
		self.__data = db.get_table(self.name)

		self.id = self.__data['Country_id'].unique()[0]
		self.code = get_alpha_3(self.name)

		temp = pd.DataFrame(load_json(countries_path))
		self.continent_id = int(temp[temp['Country_id'] == self.id]['Continent_id'].unique()[0])

		temp = load_json(continents_path)
		temp = dict([(value, key) for key, value in temp.items()])
		self.continent = temp[self.continent_id]
		del temp

		self.population = self.__data['Population'][0]
		self.last_update = self.__data['Date'].max().date()
		self.first_update = self.__data['Date'].min().date()

		self._data = self.__data.drop(columns = ['Update_time_GMT'])

		self.size = self.__data.shape
		self.columns = self.__data.columns.tolist()
Esempio n. 2
0
	def __init__(self, ttype, limit = 10, def_sort = 'TotalCases'):
		self.ttype = ttype
		self.__limit = limit
		self.sort_by = def_sort

		if ttype == 'countries':
			self.col_type = 'Country'

			self.__AllData = db.get_table('All countries updated').sort_values(by = [self.sort_by], ascending = False)
			self.__data = self.__AllData.head(self.limit)

		elif ttype == 'continents':
			self.col_type = 'Continent'

			self.__AllData = db.get_table('All continents updated').sort_values(by = [self.sort_by], ascending = False)
			self.__data = self.__AllData.head(self.limit)

		else:
			print("Couldn't Identify the requested territory")
			raise FileNotFoundError()

		self.head = self.data.head(self.limit)
		self.obj_dict = self.get_obj_dict()
Esempio n. 3
0
	def __init__(self, name):
		super().__init__(name)

		self.ttype = 'continent'

		self.__data = db.get_table(self.name)
		self.id = self.__data['Continent_id'].unique()[0]
		self.last_update = self.__data['Date'].max().date()
		self.first_update = self.__data['Date'].min().date()

		self.__data = self.__data.drop(columns = ['Update_time_GMT', 'Continent_id', 'Continent'])

		self.size = self.__data.shape
		self.columns = self.__data.columns.tolist()
Esempio n. 4
0
def get_last_row(tableName):
    row = db.get_table(tableName).tail(1)
    return row
Esempio n. 5
0
	def data(self, table):
		self.__data = db.get_table(table)
Esempio n. 6
0
	def world_map():
		df = db.get_table('All countries updated')
		df['iso_alpha'] = df['Country'].map(lambda row: get_alpha_3(row))
Esempio n. 7
0
def get_last_row(tableName):
	# TODO: Optimization problem the entire Dframe loaded.
	row = db.get_table(tableName).tail(1)
	return row