37
Explore Geopolitical data from GDELT
In this blog, we will explore the geopolitical data from GDELT and see how that data can be used in the analysis.
The GDELT Project created by Kalev H. Leetaru monitors the world's news from every country in over 100 languages and identifies the people, locations, organizations, themes, sources, emotions, counts, quotes, images, and events driving our global society.
In this blog, we will have a look at the Events database of GDELT and how this data can be used for analysis.
The GDELT Event Database catalog over 20 main categories and more than 300 subcategories. Each category is given a particular cameo code. We will be looking into the 20 main cameo codes. That includes
Let's see how we can get the data for these events for all countries.
select SQLDATE,EventRootCode,Actor1CountryCode,NumMentions from gdeltv2.events;
Using gdelt python package
- Installation:
pip install gdelt
- Call the gdelt version 2 database.
gd2 = gdelt.gdelt(version=2)
results = gd2.Search(['2020-01-01'],table='events',coverage=True)
df = pd.read_csv("gdelt.csv");
results = results[['SQLDATE','EventRootCode','NumMentions','Actor1CountryCode']]
results['SQLDATE'] = results['SQLDATE'].apply(lambda x: pd.to_datetime(str(x), format='%Y-%m-%d'))
results = results.groupby(['SQLDATE','EventRootCode','Actor1CountryCode']).agg('sum').reset_index()

Code: Link
Co-author: @ashishsalunkhe
37