Percentage of permanent residence issued to Chinese and Indian nationals in 2015, comparing with the rest of Asia

Data source: Yearbook of Immigration Statistics 2015, Homeland Security, United States


In [2]:
import pyexcel as p

base_url = "https://raw.githubusercontent.com/pyexcel/pyexcel-chart/master/"
sheet=p.get_sheet(url=base_url+"fy2015_table3d.xls")
sheet.top()


Out[2]:
pyexcel sheet:
Table 3.
PERSONS OBTAINING LAWFUL PERMANENT RESIDENT STATUS BY REGION AND COUNTRY OF BIRTH: FISCAL YEARS 2006 TO 2015
Region and country of birth 2006200720082009201020112012201320142015
REGION

Let skip the first three rows because they contain meta data only.


In [3]:
sheet=p.get_sheet(url=base_url+"fy2015_table3d.xls", start_row=3)
sheet.top()


Out[3]:
pyexcel sheet:
Region and country of birth2006 2007 2008 2009 2010 2011 2012 2013 2014 2015
REGION
Total 126612910524151107126113081810426251062040103163199055310165181051031
Africa 117421 94710 105915 127046 101355 100374 107241 98304 98413 101415
Asia 440335 397834 399027 413312 422063 451593 429599 400548430508 419297

In [4]:
sheet.name_rows_by_column(0)
sheet.row.select(['Region and country of birth','Asia', 'India', 'China, People\'s Republic'])
sheet


Out[4]:
Table 3 D:
Region and country of birth 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015
Asia 440335397834399027413312422063451593429599400548430508419297
China, People's Republic 87307 76655 80271 64238 70863 87016 81784 71798 76089 74558
India 61369 65353 63352 57304 69162 69013 66434 68458 77908 64116

In [5]:
sheet.transpose()
sheet


Out[5]:
Table 3 D:
Region and country of birth Asia China, People's Republic India
2006440335 87307 61369
2007397834 76655 65353
2008399027 80271 63352
2009413312 64238 57304
2010422063 70863 69162
2011451593 87016 69013
2012429599 81784 66434
2013400548 71798 68458
2014430508 76089 77908
2015419297 74558 64116

In [6]:
sheet.plot(chart_type='line')


Out[6]:
pyexcel chart rendered by pygal80000800001200001200001600001600002000002000002400002400002800002800003200003200003600003600004000004000004400004400002006200720082009201020112012201320142015pyexcel chart rendered by pygal44033510.88461538461538523.99621880241301200639783471.3547008547008477.270091325047252007399027131.8247863247863275.774697571500212008413312192.294871794871857.868830204006942009422063252.7649572649572546.899684573420132010451593313.23504273504279.8846153846154152011429599373.705128205128237.453509110946982012400548434.175213675213773.868164546231922013430508494.6452991452991336.314101799987842014419297555.115384615384650.3667919684838820158730710.884615384615385466.507422513396620067665571.35470085470084479.8594210572214200780271131.82478632478632475.32686128117274200864238192.2948717948718495.42380013332667200970863252.76495726495725487.11953892859145201087016313.2350427350427466.8721832697102201181784373.7051282051282473.43035604301963201271798434.1752136752137485.94754130950804201376089494.64529914529913480.5688869956184201474558555.1153846153846482.487954754780620156136910.884615384615385499.0200152874980420066535371.35470085470084494.0261773041523200763352131.82478632478632496.53437755632973200857304192.2948717948718504.11538461538464200969162252.76495726495725489.2516971639506201069013313.2350427350427489.43846469897034201166434373.7051282051282492.67117257021744201268458434.1752136752137490.134142430084201377908494.64529914529913478.28881890031073201464116555.1153846153846495.57672388683272015AsiaChina, People'…China, People's RepublicIndia

In [7]:
sheet


Out[7]:
Table 3 D:
Asia China, People's Republic India
2006440335 87307 61369
2007397834 76655 65353
2008399027 80271 63352
2009413312 64238 57304
2010422063 70863 69162
2011451593 87016 69013
2012429599 81784 66434
2013400548 71798 68458
2014430508 76089 77908
2015419297 74558 64116

In [9]:
pie_dict = {}
pie_dict['China'] = sheet['2015', 'China, People\'s Republic']/sheet['2015', 'Asia']
pie_dict['India'] = sheet['2015', 'India']/sheet['2015', 'Asia']
pie_dict['The Rest of Asia'] = 1 - pie_dict['China'] - pie_dict['India']
pie_sheet = p.get_sheet(adict=pie_dict)
pie_sheet


Out[9]:
pyexcel_sheet1:
China India The Rest of Asia
0.17781667886963180.152913090243908260.66927023088646

In [10]:
pie_sheet.plot(
    chart_type='pie', 
    legend_at_bottom=True,
    title='Percentage of permanent residence issued to Chinese and Indian nationals in 2015, comparing with the rest of Asia'
)


Out[10]:
Percentage of permanent residence issued to Chinese and Indian nationals in 2015, comparing with the rest of Asia0.1778166789435.2151357541228143.16133684137060.1529130902484.13745272045253234.296706258353450.6692702309290.21085794298875284.32367455664036Percentage of permanent residence issued to Chinese and Indian nationalsin 2015, comparing with the rest of AsiaChinaIndiaThe Rest of Asia