-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_screen_name_common_city_ids.py
34 lines (28 loc) · 1.19 KB
/
user_screen_name_common_city_ids.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# (1) load user_screen_name_sentiment_score.csv
# user_screen_names = {"__twalker__": {},
# "...":{}
# }
# (2) load tweets_geo_vaccine_us_nov_2020_to_mar_2021.csv
# tweets = [{"user_screen_name": "__twalker__", "cityID": 23},
# ...]
# (3) loop tweets
# for each tweet:
# user_screen_name = tweet["user_screen_name"]
# cityID = tweet["cityID"]
# if user_screen_name in user_screen_names.keys():
# cityIDs = user_screen_names[user_screen_name]
# if cityID in cityIDs.keys():
# cityIDs[cityID] += 1
# else:
# cityIDs[cityID] = 1
# (4) loop user_screen_names
# for user_screen_name, cityIDs in user_screen_names.items():
# most_frequent_cityID = None
# most_frequent_cityID_count = 0
# for cityID, count in cityIDs.items():
# if count > most_frequent_cityID_count:
# most_frequent_cityID = cityID
# most_frequent_cityID_count = count
# user_screen_names[user_screen_name] = most_frequent_cityID
# (5) output user_screen_names {"__twalker__": 23,
# ...}