Worldwide violent non-state attacks - Using Python, leaflet maps,...

By Younes Soliman

Its like never that you hear or read the news without facing a kind of violent attack with several kills and injuries. Lately the two events that headed the news are the terror attacks that happened on worship places in Srilanka and earlier in New Zealand.

This has raised several questions about

  • How many events usually happen per year?
  • Are the attacks and number of kills on usual trend or is it just increasing lately?
  • What is the total number of people killed because of that so far on collected records?
  • Can we see a map of top fatal attacks and be able to recognize the red zones?
  • Are we able to see the description of each attack on the map point?

Of course one can ask much more questions about the subject, thus answers can be extracted if curiosity or necessity are factors. Let's not talk more, and let's dig deeper and catch python by our hands.

The attacks can be categorized into global terror attacks, political disagreements, assassinations, occupation defense, ...etc. Noting that those are only the non-state attacks. Any kind of attacks that are generated by a registered country in the UN are not counted here. The location shown on the map is almost accurate up to country level and may be city, but not up to street level.

Take a look at the data sample. The data contains a unique eventid, the event date, location of the accident (latitude and longitude), some info about the category, the target, description, and info about the kills and injuries and some other information.

The data contains info about attacks since 1970 and up to 31/Dec/2017

Below is the sample of 5 rows

In [4]:
 
Out[4]:
eventid iyear imonth iday Approx_Date country_txt region_txt provstate city latitude ... targsubtype1_txt corp1 target1 natlty1_txt gname weaptype1_txt weapsubtype1_txt weapdetail nkill nwound
181686 201712310022 2017 12 31 2017-12-31 Somalia Sub-Saharan Africa Middle Shebelle Ceelka Geelow 2.359673 ... Military Checkpoint Somali National Army (SNA) Checkpoint Somalia Al-Shabaab Firearms Unknown Gun Type NaN 1.0 2.0
181687 201712310029 2017 12 31 2017-12-31 Syria Middle East & North Africa Lattakia Jableh 35.407278 ... Military Barracks/Base/Headquarters/Checkpost Russian Air Force Hmeymim Air Base Russia Muslim extremists Explosives Projectile (rockets, mortars, RPGs, etc.) Mortars were used in the attack. 2.0 7.0
181688 201712310030 2017 12 31 2017-12-31 Philippines Southeast Asia Maguindanao Kubentog 6.900742 ... House/Apartment/Residence Not Applicable Houses Philippines Bangsamoro Islamic Freedom Movement (BIFM) Incendiary Arson/Fire NaN 0.0 0.0
181689 201712310031 2017 12 31 2017-12-31 India South Asia Manipur Imphal 24.798346 ... Government Building/Facility/Office Forest Department Manipur Office India Unknown Explosives Grenade A thrown grenade was used in the attack. 0.0 0.0
181690 201712310032 2017 12 31 2017-12-31 Philippines Southeast Asia Maguindanao Cotabato City 7.209594 ... NaN Unknown Unknown Philippines Unknown Explosives Unknown Explosive Type An explosive device containing a detonating co... 0.0 0.0

5 rows × 23 columns

Here is the total number of events recorded in the data

In [5]:
 
Out[5]:
181691

Let's generate some stats about the kills field. The minimum is 0, while the max is 1570 in one accident. The average is about 2.4 kills per attack

In [8]:
 
Out[8]:
count    171378.000000
mean          2.403272
std          11.545741
min           0.000000
25%           0.000000
50%           0.000000
75%           2.000000
max        1570.000000
Name: nkill, dtype: float64

Now let's see how many events, kills and wounded individuals per year

In [9]:
 
Out[9]:
Events Killed Wounded
iyear
1970 651 174.0 212.0
1971 471 173.0 82.0
1972 568 566.0 409.0
1973 473 370.0 495.0
1974 581 539.0 865.0
1975 740 617.0 617.0
1976 923 674.0 756.0
1977 1319 456.0 518.0
1978 1526 1459.0 1600.0
1979 2662 2100.0 2506.0
1980 2662 4400.0 3645.0
1981 2586 4851.0 3337.0
1982 2544 5136.0 3342.0
1983 2870 9444.0 4047.0
1984 3495 10450.0 5291.0
1985 2915 7094.0 5130.0
1986 2860 4976.0 5814.0
1987 3183 6482.0 5775.0
1988 3721 7208.0 6960.0
1989 4324 8152.0 5539.0
1990 3887 7148.0 6128.0
1991 4683 8429.0 7591.0
1992 5071 9742.0 9915.0
1994 3456 7690.0 7569.0
1995 3081 6103.0 14292.0
1996 3058 6966.0 10795.0
1997 3197 10924.0 9072.0
1998 934 4688.0 8183.0
1999 1395 3393.0 5341.0
2000 1814 4403.0 5869.0
2001 1906 7729.0 22774.0
2002 1333 4805.0 7162.0
2003 1278 3317.0 7384.0
2004 1166 5743.0 12022.0
2005 2017 6331.0 12784.0
2006 2758 9380.0 15550.0
2007 3242 12824.0 22524.0
2008 4805 9157.0 18998.0
2009 4721 9273.0 19138.0
2010 4826 7827.0 15947.0
2011 5076 8246.0 14659.0
2012 8522 15497.0 25445.0
2013 12036 22273.0 37688.0
2014 16903 44490.0 41128.0
2015 14965 38853.0 44043.0
2016 13587 34871.0 40001.0
2017 10900 26445.0 24927.0

Here is the total number of killed people for these collected attacks.

In [62]:
 
Out[62]:
411868.0

Here is the total number of wounded people for these collected attacks.

In [63]:
 
Out[63]:
523869.0

Now let's plot the three measures as a continuous line chart

In [11]:
 
Out[11]:
<matplotlib.axes._subplots.AxesSubplot at 0x24af3aa6c50>

We can transfer it to a bar chart for a better view per year. We see that the number of events, kills, wounds increased lately 2012 onwards. I'm not sure this is because events are collected better at the late years or because some events target crowds

In [12]:
 
Out[12]:
<matplotlib.axes._subplots.AxesSubplot at 0x24af3b5b358>

Looking more at the last 5 years grouped data

In [67]:
 
Out[67]:
Events Killed Wounded
iyear
2013 6078 22273.0 31132.0
2014 8192 44490.0 33611.0
2015 7645 38853.0 37408.0
2016 7080 34871.0 34778.0
2017 5331 26445.0 20081.0

Now let's draw the data on leaflet map with each attack as a red point. You can zoom in to a specific country to view the collected attacks and check the target/ possible executer/ and number of kills. What is shown here are only attacks that killed 50+ individuals in order not to make it very crowded with points. In case the map didn't show in your browser, try firefox or chrome.

In [49]:
 
Out[49]:

I hope, at the end of this demonstartion, i was able to find the answers for the questions in your mind too. If you are interested in more insights, studies or work, please don't hesitate to contact.

If you like this analysis, please like and follow "Bee Eyes" page.

https://www.linkedin.com/company/bee-eyes

In [ ]: