Rise of Terrorism Project Report
Kernel: Python 2 (SageMath)
In [1]:
Out[1]:
In [92]:
Out[92]:
eventid int64
iyear int64
imonth int64
iday int64
country_txt object
city object
provstate object
latitude float64
longitude float64
location object
summary object
attacktype1 int64
attacktype1_txt object
targtype1 int64
targtype1_txt object
targsubtype1 float64
targsubtype1_txt object
natlty1 float64
natlty1_txt object
gname object
weaptype1 int64
weaptype1_txt object
nkill float64
nwound float64
date object
dtype: object
In [2]:
Out[2]:
Excersie 1. Find out which group was the ,most responsible for the Islamic terrorist attacks between 2007 and 2015. Also compare the groups to the targets.
In [3]:
Out[3]:
array(['Islamic State of Iraq and the Levant (ISIL)',
'Sinai Province of the Islamic State',
'Islamic State of Iraq (ISI)',
'Khorasan Chapter of the Islamic State',
'Sanaa Province of the Islamic State'], dtype=object)
In [22]:
Out[22]:
In [34]:
Out[34]:
gname
Adan-Abyan Province of the Islamic State 11
Algeria Province of the Islamic State 3
Bahrain Province of the Islamic State 1
Barqa Province of the Islamic State 89
Caucasus Province of the Islamic State 1
Fezzan Province of the Islamic State 3
Hadramawt Province of the Islamic State 7
Hijaz Province of the Islamic State 2
Islamic State in Bangladesh 12
Islamic State of Iraq (ISI) 144
Islamic State of Iraq and the Levant (ISIL) 2833
Khorasan Chapter of the Islamic State 78
Lahij Province of the Islamic State 2
Najd Province of the Islamic State 5
Sanaa Province of the Islamic State 29
Shabwah Province of the Islamic State 1
Sinai Province of the Islamic State 172
Supporters of the Islamic State in Jerusalem 9
Supporters of the Islamic State in the Land of the Two Holy Mosques 2
Tripoli Province of the Islamic State 144
dtype: int64
In [37]:
Out[37]:
In [61]:
Out[61]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f940c5d1fd0>
In [74]:
Out[74]:
In [114]:
Out[114]:
In [115]:
Out[115]:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-115-6204f8301adf> in <module>()
----> 1 missess = web2.pivot(index = 'iyear', columns = 'targsubtype1_txt', values = 'num_attacks')
2 missess.plot()
3 plt.ylabel("Popculture names per 1000", fontsize = 12)
4 plt.xlabel("")
5 plt.title("Modernized Names in the World", fontsize = 15)
/projects/sage/sage-7.3/local/lib/python2.7/site-packages/pandas/core/frame.pyc in pivot(self, index, columns, values)
3844 """
3845 from pandas.core.reshape import pivot
-> 3846 return pivot(self, index=index, columns=columns, values=values)
3847
3848 def stack(self, level=-1, dropna=True):
/projects/sage/sage-7.3/local/lib/python2.7/site-packages/pandas/core/reshape.pyc in pivot(self, index, columns, values)
330 indexed = Series(self[values].values,
331 index=MultiIndex.from_arrays([index, self[columns]]))
--> 332 return indexed.unstack(columns)
333
334
/projects/sage/sage-7.3/local/lib/python2.7/site-packages/pandas/core/series.pyc in unstack(self, level, fill_value)
2041 """
2042 from pandas.core.reshape import unstack
-> 2043 return unstack(self, level, fill_value)
2044
2045 # ----------------------------------------------------------------------
/projects/sage/sage-7.3/local/lib/python2.7/site-packages/pandas/core/reshape.pyc in unstack(obj, level, fill_value)
405 else:
406 unstacker = _Unstacker(obj.values, obj.index, level=level,
--> 407 fill_value=fill_value)
408 return unstacker.get_result()
409
/projects/sage/sage-7.3/local/lib/python2.7/site-packages/pandas/core/reshape.pyc in __init__(self, values, index, level, value_columns, fill_value)
99
100 self._make_sorted_values_labels()
--> 101 self._make_selectors()
102
103 def _make_sorted_values_labels(self):
/projects/sage/sage-7.3/local/lib/python2.7/site-packages/pandas/core/reshape.pyc in _make_selectors(self)
137
138 if mask.sum() < len(self.index):
--> 139 raise ValueError('Index contains duplicate entries, '
140 'cannot reshape')
141
ValueError: Index contains duplicate entries, cannot reshape
In [38]:
Out[38]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f940658a6d0>
In [73]:
Out[73]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f9406a6d290>
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
Excercise 2
In [78]:
Out[78]:
array(['Laborer (General)/Occupation Identified',
'Police Security Forces/Officers',
'Government Personnel (excluding police, military)',
'Religion Identified',
'Police Patrol (including vehicles and convoys)',
'Race/Ethnicity Identified', '.',
'Military Personnel (soldiers, troops, officers, forces)',
'Non-State Militia', 'Unnamed Civilian/Unspecified',
'Bus (excluding tourists)', 'Television Journalist/Staff/Facility',
'Military Recruiting Station/Academy',
'School/University/Educational Building', 'Place of Worship',
'Restaurant/Bar/Caf\xc3\xa9', 'Political Party Member/Rally',
'Vehicles/Transportation',
'Politician or Political Party Movement/Meeting/Rally',
'Police Building (headquarters, station, school)',
'Marketplace/Plaza/Square', 'Bank/Commerce',
'Public Area (garden, parking lot, garage, beach, public building, camp)',
'Government Building/Facility/Office', 'Religious Figure',
'Retail/Grocery/Bakery', 'Military Checkpoint',
'Judge/Attorney/Court', 'Highway/Road/Toll/Traffic Signal',
'Intelligence', 'Election-related',
'Other (including online news agencies)',
'Village/City/Town/Suburb', 'Entertainment/Cultural/Stadium/Casino',
'Police Checkpoint', 'Military Unit/Patrol/Convoy',
'Named Civilian',
'Procession/Gathering (funeral, wedding, birthday, religious)',
'Museum/Cultural Center/Cultural House', 'Hotel/Resort',
'Ambulance', 'Prison/Jail',
'Military Barracks/Base/Headquarters/Checkpost',
'Newspaper Journalist/Staff/Facility', 'Gas/Oil',
'Bus Station/Stop', 'Gas', 'International NGO',
'House/Apartment/Residence', 'Medical/Pharmaceutical',
'Teacher/Professor/Instructor', 'Radio Journalist/Staff/Facility',
'Terrorist', 'Bridge/Car Tunnel',
'Military Transportation/Vehicle (excluding convoys)',
'Refugee Camp', 'Military Aircraft', 'Affiliated Institution',
'Electricity', 'Memorial/Cemetery/Monument', 'Domestic NGO',
'Party Office/Facility', 'Airport', 'Student', 'Embassy/Consulate',
'Construction', 'Party Official/Candidate/Other Personnel',
'Farmer', 'Taxi/Rickshaw', 'Train/Train Tracks/Trolley',
'International Organization (peacekeeper, aid agency, compound)',
'Other Personnel', 'Water Supply',
'Diplomatic Personnel (outside of embassy, consulate)', 'Oil',
'Demilitarized Zone (including Green Zone)', 'Protester',
'Military Weaponry', 'Paramilitary', 'Labor Union Related',
'Military Maritime', 'Aircraft (not at an airport)',
'Industrial/Textiles/Factory', 'Tourist', 'Head of State'], dtype=object)
In [ ]:
In [ ]:
In [ ]: