Question: We need a python program that can compute and display some useful statistics on NYC agencies presence and popularity on the social media. The data
We need a python program that can compute and display some useful statistics on NYC agencies presence and popularity on the social media. The data set is released on this link:
https://catalog.data.gov/datasetyc-social-media-usage-555a2
An agency may have multiple presence on multiple social media.
The popularity of a presence is measured in terms of clicks/likes/views depending on the social platform.
Your job is to display following information:
Feature #1: Most Popular Presence (the agency and the url)
Feature #2: Report number of presence for each agency (report for all agencies one by one). For example, agency DCA has 60 presence.
Feature #3.a: Overall which social platform has the most popularity (sum of its popularities).
Feature #3.b: What is the average popularity of presences on that platform.
Ignore information that does not have popularity data.
Ignore information that does not have valid URL. A URL must start with "http://".
I need help coding ONLY FUNCTION 3b. I have coded the rest for your reference in the code below. Please need in PYTHON:

1 import cSv 2 f-open("NYC Social Hedia Usage.csv" 3 rows Csv.DictReader(f) 4 next (rows) 6 class Usage 8 platform- 18 agency url date* pres = e 12 13 14 data [] 15 16 for row in rows: 17 ifrox("Likes/Followers/visits/Donloads") 18 19 if row["Agency")" "TOTAL". ". " : 21 if int(row["Likes/Followers/Visits/Downloads"])2785886: 23 if row[ "Platform"] TOTAL" 25 if row url]TOTAL" 27 if not ro url"].1strip).startswith("http://*) 29 uUsage(O 3e u.agency rowl "Agency 31 u.platformrow[ "Platform "] 32 u.url-rourl"] 33 u.date-rowl "Date Sampled] 34 u.presint (rol Likes/Followers/visits/Downloads "]) 35 data.append (u) 36 37 maxAG= max(data, key lambda x: x.pres) 38 print( Host Popular Presence agency: maxAG.agency) 39 print("Host Popular Presence agency url: , maG.url, n") 41 def AgePRE (agency): 42 fdatafilter(lambda x: x.agency- agency, data) 43 return sum (1ist (map (lambda x: x.pres, fdata))) 45 agencies-set (map(lambda x: x. x.agency, data)) map(lambda agency: AgePRE(agency), 46 presence agencies) 48 for a, b in zip (agencies, presence): 49 print( "Agency: 58 a, "Total Popularity: , b) 52 53 def Platpre(platform): 54 fdata filter(1ambdax:x.platform.platform, data) 55 return sum (1ist (map (lambda x: x.pres, fdata))) 58 platfonmslist (set (map(lambda x: x.platform, data))) 59 Platpres list(map(1ambdax: {"pres" : Platpre(x), "platform". x), 68 maXPRE max(Platpres, key lambda x: x["pres" 61 62 platforms)) 63 print(nTHost popular platformmaxPRET platform"]:str pres"]), n") 1 import cSv 2 f-open("NYC Social Hedia Usage.csv" 3 rows Csv.DictReader(f) 4 next (rows) 6 class Usage 8 platform- 18 agency url date* pres = e 12 13 14 data [] 15 16 for row in rows: 17 ifrox("Likes/Followers/visits/Donloads") 18 19 if row["Agency")" "TOTAL". ". " : 21 if int(row["Likes/Followers/Visits/Downloads"])2785886: 23 if row[ "Platform"] TOTAL" 25 if row url]TOTAL" 27 if not ro url"].1strip).startswith("http://*) 29 uUsage(O 3e u.agency rowl "Agency 31 u.platformrow[ "Platform "] 32 u.url-rourl"] 33 u.date-rowl "Date Sampled] 34 u.presint (rol Likes/Followers/visits/Downloads "]) 35 data.append (u) 36 37 maxAG= max(data, key lambda x: x.pres) 38 print( Host Popular Presence agency: maxAG.agency) 39 print("Host Popular Presence agency url: , maG.url, n") 41 def AgePRE (agency): 42 fdatafilter(lambda x: x.agency- agency, data) 43 return sum (1ist (map (lambda x: x.pres, fdata))) 45 agencies-set (map(lambda x: x. x.agency, data)) map(lambda agency: AgePRE(agency), 46 presence agencies) 48 for a, b in zip (agencies, presence): 49 print( "Agency: 58 a, "Total Popularity: , b) 52 53 def Platpre(platform): 54 fdata filter(1ambdax:x.platform.platform, data) 55 return sum (1ist (map (lambda x: x.pres, fdata))) 58 platfonmslist (set (map(lambda x: x.platform, data))) 59 Platpres list(map(1ambdax: {"pres" : Platpre(x), "platform". x), 68 maXPRE max(Platpres, key lambda x: x["pres" 61 62 platforms)) 63 print(nTHost popular platformmaxPRET platform"]:str pres"]), n")
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
