How to get Trends for a Certain Location in Twitter using Python

  1. JSON response of the above request: the response will contain the woeid for each place
import tweepy as tw
import pandas as pd
auth = tw.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tw.API(auth, wait_on_rate_limit=True)
# WOEID of London 
woeid = 44418

# getting the trends
trends = api.trends_place(id = woeid)

# printing the Trends and Their counts
print(“The trends for the location are :”)

for value in trends:
for trend in value[‘trends’]:
print(trend[‘name’], ‘===============> Count =’ , trend[‘tweet_volume’])

Phd Student of Computer Science

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to Select and Filter Data in Pandas

Household location in English cities

Entity Matching

Principal Components: Kristen Werner on Streamlining the Data Supply Chain

ARIMA vs. Prophet: Forecasting Air Passenger Numbers

How many Taiwanese live in the U.S.? It’s not an easy question to answer

How to Make Word Clouds People Won’t Hate

Poker Chips Verdeling

Poker chips with denominations

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Esraa N.

Esraa N.

Phd Student of Computer Science

More from Medium

Categorical Coding in Excel

Data Structure in Python

Topic: Coding made Simple

A laptop showing a blank screen

Working with missing data on Pandas