Exploring the geographic information available in profiles
The Twitter users' profiles contain two different, potential sources of geographic information: the profile itself and the most recently tweeted status update. We will utilize both options in this recipe with an eye towards usability in constructing a geographic visualization of our friends.
Getting ready
You will need the harvested friends' and/or followers' profiles from Twitter, as directed in the previous recipes.
How to do it...
Perform the following steps to extract the geographic data that we need to visualize the approximate locations of our connections:
- We start this exercise in IPython or your favorite Python REPL. Load your friends' profiles from the file:
In[1]: fname = 'test_friends_profiles.json'
In[2]: load_json(fname)
- Next, we build lists from all of the values of the
geo_enabled
field in the user profiles' data structures for our friends. Then, we use thecount
method to find the number of user profiles that have the...