Python Pandas outlines for data analysis for Gun Ownership in World. The data is [here][Pandas analysis].
Gun Ownership in World |
Source code
The following outlines the Python code used:
import numpy as np import pandas as pd import sys import matplotlib.pyplot as plt xval = 'Violent Crime'; yval = 'Murder'; file='1111' ver=pd.read_csv("city.csv") plt.xlabel(xval) plt.ylabel(yval) plt.scatter(ver[xval],ver[yval]) plt.show() f2= file+".svg" plt.savefig(f2,format='SVG') f2= file+".png" plt.savefig(f2,format='PNG')
Data
The data used is [here]
Country,"Firearm-related DR per 100K pop per year",Homicides ,Suicides ,Unintentional ,Undetermined ,Guns ownership (%) Argentina,6.36,2.58,1.57,0.05,2.57,10.2 Australia,0.93,0.16,0.74,0.02,0.02,21.7 Austria,2.63,0.1,2.43,0.01,0.04,30.4 Azerbaijan,0.3,0.27,0.01,0.02,0,3.5 Barbados,3.12,3.12,0,0,0,7.8 Belarus,0.23,0.14,0,0.09,0,7.3 Bolivia,0.74,0.74,0,0,0,2.8 Brazil,19.72,18.79,0.74,0.18,0.01,8 Bulgaria,1.71,0.34,0.97,0.23,0.1,6.2 Canada,1.97,0.38,1.52,0.05,0.02,30.8 Chile,1.95,1.02,0.81,0.08,0.04,10.7 Colombia,25.94,23.93,0.87,0.11,1.03,5.9 Costa Rica,7.5,5.92,1.27,0.07,0.24,9.9 Croatia,2.68,0.4,2.37,0.05,0.02,21.7 Cyprus,1.87,1.05,0.58,0.12,0.12,36.4 Czech Republic,2.01,0.15,1.66,0.09,0.13,16.3 Denmark,1.28,0.22,1.09,0.04,0.02,12 El Salvador,26.77,26.49,0.13,0.15,0,5.8 Estonia,2.67,0.15,2.11,0.15,0.3,9.2 Finland,3.25,0.32,2.94,0.02,0.02,27.5 France,2.83,0.21,2.16,0.04,0.41,31.2 Georgia,1.98,0.49,0.09,1,0.4,7.3 Germany,1.01,0.07,0.84,0.01,0.08,30.3 Greece,1.52,0.53,0.86,0.06,0,22.5 Guatemala,34.1,29.62,0.34,1.33,2.81,13.1 Honduras,67.18,66.64,0.41,0.13,0,6.2 Hungary,0.95,0.11,0.81,0.02,0.02,5.5 Iceland,1.25,0,1.25,0,0,30.3 India,0.28,0.3,0.14,0.04,0,4.2 Israel,2.1,1.04,0.67,0.05,0.26,7.3 Italy,1.31,0.35,0.87,0.09,0.02,11.9 Jamaica,30.72,30.38,0.34,0,0,8.1 Japan,0.06,0,0.04,0.01,0.01,0.6 Kuwait,0.36,0.36,0,0,0,24.8 Kyrgyzstan,1.01,0.53,0.07,0.28,0.13,0.9 Latvia,1.43,0.18,0.94,0.04,0.27,19 Luxembourg,1.19,0,1.16,0.22,0.39,15.3 Mexico,7.64,6.34,0.44,0.4,0.46,15 Moldova,1.03,0.45,0.42,0.08,0.08,7.1 Montenegro,8.91,2.42,6.49,0,0,23.1 Netherlands,0.58,0.29,0.28,0.01,0.01,3.9 New Zealand,1.07,0.18,0.84,0.05,0,22.6 Nicaragua,4.68,3.72,0.34,0.16,0.46,7.7 Norway,1.75,0.1,1.63,0.02,0,31.3 Panama,15.11,14.36,0.57,0.06,0.12,21.7 Paraguay,7.76,5.78,1.16,0.3,0.52,17 Peru,5.53,4.22,0.07,0.93,0.31,18.8 Philippines,8.9,8.9,0,0,0,4.7 Poland,0.26,0.04,0.09,0.03,0.1,1.3 Portugal,1.58,0.42,1.01,0.03,0.12,8.5 Qatar,0.15,0.15,0,0,0,19.2 Romania,0.14,0.04,0.06,0.04,0,0.7 Serbia,3.49,0.61,2.49,0.14,0.29,0.6 Singapore,0.16,0.02,0.12,0.02,0,0.5 Slovakia,1.83,0.26,0.94,0.39,0.24,8.3 Slovenia,2.64,0.2,2.34,0.05,0.05,13.5 South Africa,8.3,8.2,0.1,0.02,0.11,12.7 South Korea,0.08,0.02,0.04,0.01,0.01,1.1 Spain,0.62,0.15,0.42,0.05,0,10.4 Swaziland,37.16,37.16,0,0,0,6.4 Sweden,1.47,0.19,1.2,0.06,0.01,31.6 Switzerland,3.08,0.23,2.68,0.1,0.07,45.7 Taiwan,0.87,0.6,0.12,0.11,0.04,4.6 Ukraine,0.24,0.24,0,0,0,6.6 United Kingdom,0.23,0.06,0.15,0,0.02,6.6 United States,10.54,3.43,6.69,0.18,0.08,112.6 Uruguay,11.52,4.78,4.68,2,0.06,31.8 Venezuela,59.13,39,0.48,0.17,19.48,10.7 Zimbabwe,0.39,0.3,0.09,0,0,4.6