Analyzing Social Media Data in Python
Alex Hanna
Computational Social Scientist
print(tweet['user']['location'])
Bay Area
print(tweet['place'])
{'attributes': {},
'bounding_box': {'coordinates':
[[[-80.47611, 37.185195],
[-80.47611, 37.273387],
[-80.381618, 37.273387],
[-80.381618, 37.185195]]],
'type': 'Polygon'},
'country': 'United States',
'country_code': 'US',
'full_name': 'Blacksburg, VA',
'name': 'Blacksburg',
'place_type': 'city',
...}
coordinates = [
[-80.47611, 37.185195],
[-80.47611, 37.273387],
[-80.381618, 37.273387],
[-80.381618, 37.185195]]
longs = np.unique( [x[0] for x
in coordinates] )
lats = np.unique( [x[1] for x
in coordinates] )
central_long = np.sum(longs) / 2
central_lat = np.sum(lats) / 2
print(tweet['coordinates'])
{'type': 'Point',
'coordinates': [-72.2833,
21.7833]}
Analyzing Social Media Data in Python