3. Device Type over Time
Source: https://www.nakono.com/tekcarta/company-profiles/microsoft-xbox-one/microsoft-xbox-360-and-
xbox-one-developer-programme-market-adoption-and-analysis/
4. Usage by Time of Day
Source: http://downloads.bbc.co.uk/mediacentre/iplayer/iplayer-performance-jan16.pdf
14. Read in SQLite dump as dictionary
reader = csv.DictReader(my_file, delimiter='t')
print(reader.fieldnames)
urls = [(row['url'], row['title'], row['visit_count'])
for row in reader
if 'bbc.co.uk' in row['url']]
for url, title, visitcount in urls:
print(url, '|', title, '|', visitcount)
['id', 'url', 'title', 'visit_count', 'typed_count', 'last_visit_ti
http://www.bbc.co.uk/iplayer | BBC iPlayer | 53
http://www.bbc.co.uk/iplayer/guide | BBC iPlayer - TV Guide - Londo
http://www.bbc.co.uk/iplayer/live/bbcone | BBC iPlayer - Watch BBC
http://www.bbc.co.uk/iplayer/a-z | BBC iPlayer - A to Z - A | 4
16. Users table
users
user_id (PK) 12346
first_name Regen
last_name Schattschneid
date_of_birth 1963-11-22
region South East England
gender m
email_address regen.schattschneid@coelurosauria.com
18. Distribute Users among Regions
region_distribution = [('NORTH EAST ENGLAND', 0.14),
('THE MIDLANDS', 0.13),
('NORTH WEST ENGLAND', 0.12),
('EAST ANGLIA', 0.11),
('SOUTH CENTRAL ENGLAND', 0.1),
('SOUTH EAST ENGLAND', 0.09),
('SCOTLAND', 0.08),
('LONDON', 0.08),
('SOUTH WEST ENGLAND', 0.08),
('WALES', 0.04),
('NORTHERN IRELAND', 0.03)]
my_region = get_random_key(region_distribution)
19. Find Random Key,
given List of Key, Probabilities
def get_random_key(list_of_distribution_tuples):
rnd = random.random()
cumulative_probability = 0.0
for (key, probability) in list_of_distribution_tuples:
cumulative_probability += probability
if rnd <= cumulative_probability:
return key
my_region = get_random_key(region_distribution)