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]:
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]:
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]:
In [5]:
sheet.transpose()
sheet
Out[5]:
In [6]:
sheet.plot(chart_type='line')
Out[6]:
In [7]:
sheet
Out[7]:
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]:
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]: