{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "df = pd.read_csv('journalistskilled.csv')\n", "year=[]\n", "for i in range(0,1324):\n", " individualyear=df['date'][i][-4:]\n", " year.append(individualyear)\n", "df['years']=year\n", "\n", "country=[]\n", "for i in range(0,1324):\n", " individualcountry=df['location'][i].split()[-1]\n", " country.append(individualcountry)\n", "country\n", "df['country']=country" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 1. What are the most dangerous countries for journalists?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The following map is an interaction diagram(svg). The deeper the color of a country, the more news workers were killed in that country and the more dangerous it is for reporters. Also, If your mouse stop on a country, it will show the number of jounalists killed in that country." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "scrolled": false }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "for a in [113,250,676,966]:\n", " df['country'][a]='Central African Republic'\n", "for b in [609,631,632]:\n", " df['country'][b]='Dominican Republic'\n", "dfcountry=df['country'].replace({'Syria':'Syrian Arab Republic','Russia':'Russian Federation','Territory':'Israel','Lanka':'Sri Lanka','Bosnia':'Bosnia and Herzegovina','Leone':'Sierra Leone','Libya':'Libyan Arab Jamahiriya','USA':'United States','Yugoslavia':'Serbia','Venezuela':'Bolivarian Republic of Venezuela','Iran':'Islamic Republic of Iran','Africa':'South Africa','Salvador':'El Salvador','Coast':'Cote d’Ivoire','Timor':'Timor-Leste','Bolivia':'Plurinational State of Bolivia','Arabia':'Saudi Arabia','Faso':'Burkina Faso','Rica':'Costa Rica','UK':'United Kingdom'}).value_counts()\n", "\n", "dictallcountries1=dfcountry.to_dict()\n", "dictallcountries1.values()\n", "dictallcountries1values=list(dictallcountries1.values())\n", "countryname1=list(dictallcountries1)\n", "\n", "ctcode = pd.read_csv('country code.csv')\n", "for word in countryname1:\n", " for k in range(len(ctcode)):\n", " if word==ctcode['Country'][k]:\n", " n=countryname1.index(word)\n", " countryname1.remove(word)\n", " countryname1.insert(n,ctcode['code'][k])\n", "\n", "dictallcountries = dict(zip(countryname1,dictallcountries1values))\n", "\n", "import pygal.maps.world\n", "worldmap_chart = pygal.maps.world.World()\n", "worldmap_chart.title = 'Number of Journalists Killed in Different Countries'\n", "worldmap_chart.add('Since 1992',dictallcountries)\n", "worldmap_chart.render_to_file('Number of Journalists Killed in Different Countries.svg')\n", "from IPython.display import IFrame\n", "IFrame('Number of Journalists Killed in Different Countries.html', width=800, height=600)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "worldmap_chart.render_in_browser()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Also, in the following map, the deeper the color of a country, the more news workers were imprisoned in that country." ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "scrolled": false }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dictimprisoned=pd.read_csv('IMPRISONED.csv',header=None,index_col=0).to_dict()[1]\n", "import pygal.maps.world\n", "worldmap_chart1 = pygal.maps.world.World()\n", "worldmap_chart1.title = 'Number of Journalists Imprisoned in Different Courntries'\n", "worldmap_chart1.add('2008-2016',dictimprisoned)\n", "worldmap_chart1.render_to_file('Number of Journalists Imprisoned in Different Countries.svg')\n", "from IPython.display import IFrame\n", "IFrame('Number of Journalists Imprisoned in Different Countries.html', width=800, height=600)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Iran and Syria are the two most dangerous countries for journalists." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pie_chart = pygal.Pie(inner_radius=.75)\n", "pie_chart.title = 'Suspected Source of Fire that killed Iraqi Journalists between 2003 and 2008'\n", "pie_chart.add('Political Group', 87)\n", "pie_chart.add('Military Officials', 14)\n", "pie_chart.add('Unknown Fire', 8)\n", "pie_chart.add('Criminal Group', 2)\n", "pie_chart.render_to_file('Suspected Source of Fire that killed Iraqi Journalists between 2003 and 2008.svg')\n", "from IPython.display import IFrame\n", "IFrame('Suspected Source of Fire that killed Iraqi Journalists between 2003 and 2008.html', width=800, height=600)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pie_chart = pygal.Pie(half_pie=True)\n", "pie_chart.title = 'Types of Deaths of Journalists Killed in Iraq between 2003-2008'\n", "pie_chart.add('Crossfire', 34)\n", "pie_chart.add('Murder', 77)\n", "pie_chart.render_to_file('Types of Deaths of Journalists Killed in Iraq between 2003-2008.svg')\n", "from IPython.display import IFrame\n", "IFrame('Types of Deaths of Journalists Killed in Iraq between 2003-2008.html', width=800, height=600)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pie_chart = pygal.Pie(inner_radius=.75)\n", "pie_chart.title = 'Suspected Source of Fire that killed Journalists in Syria between 2003 and 2008'\n", "pie_chart.add('Political Group', 28)\n", "pie_chart.add('Military Officials', 63)\n", "pie_chart.add('Unknown Fire', 21)\n", "pie_chart.add('Government Officials', 4)\n", "pie_chart.add('Military Officials, Political Group', 2)\n", "pie_chart.add('Paramilitary Group', 1)\n", "pie_chart.add('Political Group, Paramilitary Group', 1)\n", "pie_chart.add('Local Residents, Political Group', 1)\n", "pie_chart.render_to_file('Suspected Source of Fire that killed Journalists in Syria between 2003 and 2008.svg')\n", "from IPython.display import IFrame\n", "IFrame('Suspected Source of Fire that killed Journalists in Syria between 2003 and 2008.html', width=800, height=600)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "scrolled": false }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pie_chart = pygal.Pie(half_pie=True)\n", "pie_chart.title = 'Types of Deaths of Journalists Killed in Syria after 2011'\n", "pie_chart.add('Crossfire', 95)\n", "pie_chart.add('Murder', 18)\n", "pie_chart.add('Dangerous Assignment', 6)\n", "pie_chart.add('Unknown', 2)\n", "pie_chart.render_to_file('Types of Deaths of Journalists Killed in Syria after 2011.svg')\n", "from IPython.display import IFrame\n", "IFrame('Types of Deaths of Journalists Killed in Syria after 2011.html', width=800, height=600)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 2. How many journalists were killed each year since 1992?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can see that 2009 was the year when the most journalists were killed, while 2002 the least. Also, there were 2 journalists whose date of death still remained unclear." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pygal\n", "line_chart = pygal.Line(width=1000)\n", "line_chart.title = 'Number of Journalists Killed from 1992-2018'\n", "line_chart.x_labels = map(str, range(1992, 2019))\n", "line_chart.add('death toll',[44, 56, 66, 51, 26, 26, 24, 36, 24, 37, 21, 42, 61, 50, 57, 69, 42, 75, 44, 49, 74, 73, 61, 73, 50, 46, 45])\n", "line_chart.render_to_file('Number of Journalists Killed from 1992-2018.svg')\n", "from IPython.display import IFrame\n", "IFrame('Number of Journalists Killed from 1992-2018.html', width=800, height=600)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 3. What did the reporters die of?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As is shown in the pie chart below, nearly 64.1% of news workers were killed by murder. 22.6% of them died under crossfire and 12.8% during dangerous assignment. The deaths of 2 journalists cannot be ascertained." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pie_chart = pygal.Pie(inner_radius=.4)\n", "pie_chart.title = 'Suspected Source of Fire'\n", "pie_chart.add('Political Group', 430)\n", "pie_chart.add('Military Officials',238)\n", "pie_chart.add('Unknown Fire',209)\n", "pie_chart.add('Government Officials',194)\n", "pie_chart.add('Criminal Group',117)\n", "pie_chart.add('Paramilitary Group',58)\n", "pie_chart.add('Local Residents',30)\n", "pie_chart.add('Mob Violence',14)\n", "pie_chart.add('Combination of More Than one Sources of Fire',34)\n", "pie_chart.render_to_file('Suspected Source of Fire.svg')\n", "from IPython.display import IFrame\n", "IFrame('Suspected Source of Fire.html', width=800, height=600)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.0" } }, "nbformat": 4, "nbformat_minor": 2 }