{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Data Exploration\n", "\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true, "scrolled": true }, "outputs": [], "source": [ "import os\n", "import pandas as pd\n", "import settings\n", "\n", "% matplotlib inline" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
NationYearPop
0North America1980320.27638
1Bermuda19800.05473
2Argentina198028.3698
3Former U.S.S.R.1980265.92182
4Georgia1980--
\n", "
" ], "text/plain": [ " Nation Year Pop\n", "0 North America 1980 320.27638\n", "1 Bermuda 1980 0.05473\n", "2 Argentina 1980 28.3698\n", "3 Former U.S.S.R. 1980 265.92182\n", "4 Georgia 1980 --" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.read_csv(os.path.join(settings.data_dir, 'pop_by_country_long_form.csv'))\n", "df['Year'] = df['Year'].str[4:].astype(int)\n", "df.head()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "array(['North America', 'Bermuda', 'Argentina', 'Former U.S.S.R.',\n", " 'Georgia', 'Kazakhstan', 'Kyrgyzstan', 'Latvia', 'Lithuania',\n", " 'Moldova', 'Russia', 'Tajikistan', 'Turkmenistan', 'Aruba',\n", " 'Ukraine', 'Uzbekistan', 'Middle East', 'Bahrain', 'Iran', 'Iraq',\n", " 'Israel', 'Jordan', 'Kuwait', 'Lebanon', 'Bahamas, The', 'Oman',\n", " 'Palestine', 'Qatar', 'Saudi Arabia', 'Syria',\n", " 'United Arab Emirates', 'Yemen', 'Africa', 'Algeria', 'Angola',\n", " 'Barbados', 'Benin', 'Botswana', 'Burkina Faso', 'Burundi',\n", " 'Cameroon', 'Cape Verde', 'Central African Republic', 'Chad',\n", " 'Comoros', 'Congo (Brazzaville)', 'Belize', 'Congo (Kinshasa)',\n", " 'Cote dIvoire (IvoryCoast)', 'Djibouti', 'Egypt',\n", " 'Equatorial Guinea', 'Eritrea', 'Ethiopia', 'Gabon', 'Gambia, The',\n", " 'Ghana', 'Bolivia', 'Guinea', 'Guinea-Bissau', 'Kenya', 'Lesotho',\n", " 'Liberia', 'Libya', 'Madagascar', 'Malawi', 'Mali', 'Mauritania',\n", " 'Brazil', 'Mauritius', 'Morocco', 'Mozambique', 'Namibia', 'Niger',\n", " 'Nigeria', 'Reunion', 'Rwanda', 'Saint Helena',\n", " 'Sao Tome and Principe', 'Cayman Islands', 'Senegal', 'Seychelles',\n", " 'Sierra Leone', 'Somalia', 'South Africa', 'Sudan', 'Swaziland',\n", " 'Tanzania', 'Togo', 'Tunisia', 'Chile', 'Uganda', 'Western Sahara',\n", " 'Zambia', 'Zimbabwe', 'Asia & Oceania', 'Afghanistan',\n", " 'American Samoa', 'Australia', 'Bangladesh', 'Bhutan', 'Colombia',\n", " 'Brunei', 'Burma (Myanmar)', 'Cambodia', 'China', 'Cook Islands',\n", " 'Fiji', 'French Polynesia', 'Guam', 'Hawaiian Trade Zone',\n", " 'Hong Kong', 'Canada', 'Costa Rica', 'India', 'Indonesia', 'Japan',\n", " 'Kiribati', 'Korea, North', 'Korea, South', 'Laos', 'Macau',\n", " 'Malaysia', 'Maldives', 'Cuba', 'Mongolia', 'Nauru', 'Nepal',\n", " 'New Caledonia', 'New Zealand', 'Niue', 'Pakistan',\n", " 'Papua New Guinea', 'Philippines', 'Samoa', 'Dominica', 'Singapore',\n", " 'Solomon Islands', 'Sri Lanka', 'Taiwan', 'Thailand',\n", " 'Timor-Leste (East Timor)', 'Tonga', 'U.S. Pacific Islands',\n", " 'Vanuatu', 'Vietnam', 'Dominican Republic', 'Wake Island', 'World',\n", " 'Ecuador', 'El Salvador', 'Falkland Islands (Islas Malvinas)',\n", " 'French Guiana', 'Grenada', 'Guadeloupe', 'Greenland', 'Guatemala',\n", " 'Guyana', 'Haiti', 'Honduras', 'Jamaica', 'Martinique',\n", " 'Montserrat', 'Netherlands Antilles', 'Nicaragua', 'Panama',\n", " 'Mexico', 'Paraguay', 'Peru', 'Puerto Rico',\n", " 'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Vincent/Grenadines',\n", " 'Suriname', 'Trinidad and Tobago', 'Turks and Caicos Islands',\n", " 'Uruguay', 'Saint Pierre and Miquelon', 'Venezuela',\n", " 'Virgin Islands, U.S.', 'Virgin Islands, British', 'Europe',\n", " 'Albania', 'Austria', 'Belgium', 'Bosnia and Herzegovina',\n", " 'Bulgaria', 'Croatia', 'United States', 'Cyprus', 'Czech Republic',\n", " 'Denmark', 'Faroe Islands', 'Finland', 'Former Czechoslovakia',\n", " 'Former Serbia and Montenegro', 'Former Yugoslavia', 'France',\n", " 'Germany', 'Central & South America', 'Germany, East',\n", " 'Germany, West', 'Gibraltar', 'Greece', 'Hungary', 'Iceland',\n", " 'Ireland', 'Italy', 'Luxembourg', 'Macedonia', 'Antarctica',\n", " 'Malta', 'Montenegro', 'Netherlands', 'Norway', 'Poland',\n", " 'Portugal', 'Romania', 'Serbia', 'Slovakia', 'Slovenia',\n", " 'Antigua and Barbuda', 'Spain', 'Sweden', 'Switzerland', 'Turkey',\n", " 'United Kingdom', 'Eurasia', 'Armenia', 'Azerbaijan', 'Belarus',\n", " 'Estonia'], dtype=object)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.Nation.drop_duplicates().values" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Object `to_json` not found.\n" ] } ], "source": [ "nation = 'United States'\n", "df2 = df.groupby(['Year', 'Nation']).sum().unstack()\n", "df2.columns = df2.columns.droplevel()#[nation]\n", "df2[[nation]].rename(columns={'United States':'Series', 'Year':'Values'}).to_json?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "df2[[nation]].rename(columns={'United States':'Series', 'Year':'Values'}).to_json" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df2[[nation]].rename(columns={'United States':'Series', 'Year':'Values'}).to_json" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'labels:[1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010], series: [[227.22468, 229.46571, 231.66446, 233.79199, 235.8249, 237.9238, 240.13289, 242.28892, 244.49898, 246.81923, 249.62281, 252.98094, 256.51422, 259.91859, 263.12582, 266.27839, 269.39428, 272.64693, 275.8541, 279.04017, 282.17196, 285.08156, 287.80391, 290.32642, 293.04574, 295.75315, 298.59321, 301.5799, 304.37485, 307.00655, 310.23286]]'" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "f'labels:{df2.index.astype(int).tolist()}, series: [{df2[nation].astype(float).tolist()}]'" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": true }, "outputs": [], "source": [ "df = pd.read_csv(os.path.join(settings.data_dir, 'pop_by_country_long_form.csv'))\n", "df['Year'] = df['Year'].str[4:].astype(int)\n", "df2 = df.groupby(['Year', 'Nation']).sum().unstack()\n", "df2.columns = df2.columns.droplevel()\n", "nations = df2.columns" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBOR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utPVXx4y2U/zbSyVqbWPHYJso/fwOBx8547C7gzbpLXjnV\nHZ+1diZAxQx3LnB1HUevlMqMz1qbfMbd54LPMv7kH3r/2lwVkwrcZK2dCrSq+H6UtfbnlM9k7wZ2\nABcBGGN6Akdqcfu+lso5xmeMaWCMaWitzQOygGCnwlZRKv89tsXW2puAp4AiIBGINeWCgLb+XOrf\nk8q5x4cxprEt3y2RALR1JmrlGGNiKN919Lm19n7K/7NtXfHjocBu4KgxpkfFYyOA7ZzxGTzjMb9T\n3fEZYxpXfJ9K+YzXL1VyfGc618+/o7YPKi0xxniAd621p40xq40xSykvuDnW2jXGmJHGmMWU75e+\np5a372s/Oj4gBnjSGFMGrLHW5joZtoq+P7ZxxphJlP8bmWatzTLGLAKWUr4LY4aDWavjR8dnjGkC\nvGOMKaZ8v/uzToathHsoL64pxpgpwIPAG8aYUuATa21SxWxwTsW/xyRr7QZjzDbgZWPMryiffPzO\nqQGcQ3XhQIqWAAABG0lEQVTHd6sx5irKf8t8yrH053bO8X3v+Q+c4+ffoeWOIiIuozNPRURcRsUu\nIuIyKnYREZdRsYuIuIyKXVzLGPN8xdmyGGO6G2M+PmM53Lleq8+GBCytihHXqijxZZSfQ/ES8Fvg\nPqAQaA1MpXyZajHQhvIlnI8BHmCptXalA7FFakyzEnEta20p5WdWrqG82McB51F+fY4Qys87OAjk\nUb6m+NsTdx5XqUsgU7GLq1lrDwOp1tqPKx5aZ639I/AacJrys4cfofw6Md/upvHUfVKR2qNil/rk\nHWCUMWY25Vd7PEr5qdrPATc7mkykFmkfu4iIy2jGLiLiMip2ERGXUbGLiLiMil1ExGVU7CIiLqNi\nFxFxGRW7iIjL/H/U9KEeLyXnkAAAAABJRU5ErkJggg==\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig, ax = plt.subplots()\n", "df2[nations[12]].astype(float).plot(ax=ax);" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": true }, "outputs": [], "source": [ "items = ['mpl/' + nation for nation in df2.columns]" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[('mpl/Afghanistan', 'mpl/Afghanistan'),\n", " ('mpl/Africa', 'mpl/Africa'),\n", " ('mpl/Albania', 'mpl/Albania'),\n", " ('mpl/Algeria', 'mpl/Algeria'),\n", " ('mpl/American Samoa', 'mpl/American Samoa'),\n", " ('mpl/Angola', 'mpl/Angola'),\n", " ('mpl/Antarctica', 'mpl/Antarctica'),\n", " ('mpl/Antigua and Barbuda', 'mpl/Antigua and Barbuda'),\n", " ('mpl/Argentina', 'mpl/Argentina'),\n", " ('mpl/Armenia', 'mpl/Armenia'),\n", " ('mpl/Aruba', 'mpl/Aruba'),\n", " ('mpl/Asia & Oceania', 'mpl/Asia & Oceania'),\n", " ('mpl/Australia', 'mpl/Australia'),\n", " ('mpl/Austria', 'mpl/Austria'),\n", " ('mpl/Azerbaijan', 'mpl/Azerbaijan'),\n", " ('mpl/Bahamas, The', 'mpl/Bahamas, The'),\n", " ('mpl/Bahrain', 'mpl/Bahrain'),\n", " ('mpl/Bangladesh', 'mpl/Bangladesh'),\n", " ('mpl/Barbados', 'mpl/Barbados'),\n", " ('mpl/Belarus', 'mpl/Belarus'),\n", " ('mpl/Belgium', 'mpl/Belgium'),\n", " ('mpl/Belize', 'mpl/Belize'),\n", " ('mpl/Benin', 'mpl/Benin'),\n", " ('mpl/Bermuda', 'mpl/Bermuda'),\n", " ('mpl/Bhutan', 'mpl/Bhutan'),\n", " ('mpl/Bolivia', 'mpl/Bolivia'),\n", " ('mpl/Bosnia and Herzegovina', 'mpl/Bosnia and Herzegovina'),\n", " ('mpl/Botswana', 'mpl/Botswana'),\n", " ('mpl/Brazil', 'mpl/Brazil'),\n", " ('mpl/Brunei', 'mpl/Brunei'),\n", " ('mpl/Bulgaria', 'mpl/Bulgaria'),\n", " ('mpl/Burkina Faso', 'mpl/Burkina Faso'),\n", " ('mpl/Burma (Myanmar)', 'mpl/Burma (Myanmar)'),\n", " ('mpl/Burundi', 'mpl/Burundi'),\n", " ('mpl/Cambodia', 'mpl/Cambodia'),\n", " ('mpl/Cameroon', 'mpl/Cameroon'),\n", " ('mpl/Canada', 'mpl/Canada'),\n", " ('mpl/Cape Verde', 'mpl/Cape Verde'),\n", " ('mpl/Cayman Islands', 'mpl/Cayman Islands'),\n", " ('mpl/Central & South America', 'mpl/Central & South America'),\n", " ('mpl/Central African Republic', 'mpl/Central African Republic'),\n", " ('mpl/Chad', 'mpl/Chad'),\n", " ('mpl/Chile', 'mpl/Chile'),\n", " ('mpl/China', 'mpl/China'),\n", " ('mpl/Colombia', 'mpl/Colombia'),\n", " ('mpl/Comoros', 'mpl/Comoros'),\n", " ('mpl/Congo (Brazzaville)', 'mpl/Congo (Brazzaville)'),\n", " ('mpl/Congo (Kinshasa)', 'mpl/Congo (Kinshasa)'),\n", " ('mpl/Cook Islands', 'mpl/Cook Islands'),\n", " ('mpl/Costa Rica', 'mpl/Costa Rica'),\n", " ('mpl/Cote dIvoire (IvoryCoast)', 'mpl/Cote dIvoire (IvoryCoast)'),\n", " ('mpl/Croatia', 'mpl/Croatia'),\n", " ('mpl/Cuba', 'mpl/Cuba'),\n", " ('mpl/Cyprus', 'mpl/Cyprus'),\n", " ('mpl/Czech Republic', 'mpl/Czech Republic'),\n", " ('mpl/Denmark', 'mpl/Denmark'),\n", " ('mpl/Djibouti', 'mpl/Djibouti'),\n", " ('mpl/Dominica', 'mpl/Dominica'),\n", " ('mpl/Dominican Republic', 'mpl/Dominican Republic'),\n", " ('mpl/Ecuador', 'mpl/Ecuador'),\n", " ('mpl/Egypt', 'mpl/Egypt'),\n", " ('mpl/El Salvador', 'mpl/El Salvador'),\n", " ('mpl/Equatorial Guinea', 'mpl/Equatorial Guinea'),\n", " ('mpl/Eritrea', 'mpl/Eritrea'),\n", " ('mpl/Estonia', 'mpl/Estonia'),\n", " ('mpl/Ethiopia', 'mpl/Ethiopia'),\n", " ('mpl/Eurasia', 'mpl/Eurasia'),\n", " ('mpl/Europe', 'mpl/Europe'),\n", " ('mpl/Falkland Islands (Islas Malvinas)',\n", " 'mpl/Falkland Islands (Islas Malvinas)'),\n", " ('mpl/Faroe Islands', 'mpl/Faroe Islands'),\n", " ('mpl/Fiji', 'mpl/Fiji'),\n", " ('mpl/Finland', 'mpl/Finland'),\n", " ('mpl/Former Czechoslovakia', 'mpl/Former Czechoslovakia'),\n", " ('mpl/Former Serbia and Montenegro', 'mpl/Former Serbia and Montenegro'),\n", " ('mpl/Former U.S.S.R.', 'mpl/Former U.S.S.R.'),\n", " ('mpl/Former Yugoslavia', 'mpl/Former Yugoslavia'),\n", " ('mpl/France', 'mpl/France'),\n", " ('mpl/French Guiana', 'mpl/French Guiana'),\n", " ('mpl/French Polynesia', 'mpl/French Polynesia'),\n", " ('mpl/Gabon', 'mpl/Gabon'),\n", " ('mpl/Gambia, The', 'mpl/Gambia, The'),\n", " ('mpl/Georgia', 'mpl/Georgia'),\n", " ('mpl/Germany', 'mpl/Germany'),\n", " ('mpl/Germany, East', 'mpl/Germany, East'),\n", " ('mpl/Germany, West', 'mpl/Germany, West'),\n", " ('mpl/Ghana', 'mpl/Ghana'),\n", " ('mpl/Gibraltar', 'mpl/Gibraltar'),\n", " ('mpl/Greece', 'mpl/Greece'),\n", " ('mpl/Greenland', 'mpl/Greenland'),\n", " ('mpl/Grenada', 'mpl/Grenada'),\n", " ('mpl/Guadeloupe', 'mpl/Guadeloupe'),\n", " ('mpl/Guam', 'mpl/Guam'),\n", " ('mpl/Guatemala', 'mpl/Guatemala'),\n", " ('mpl/Guinea', 'mpl/Guinea'),\n", " ('mpl/Guinea-Bissau', 'mpl/Guinea-Bissau'),\n", " ('mpl/Guyana', 'mpl/Guyana'),\n", " ('mpl/Haiti', 'mpl/Haiti'),\n", " ('mpl/Hawaiian Trade Zone', 'mpl/Hawaiian Trade Zone'),\n", " ('mpl/Honduras', 'mpl/Honduras'),\n", " ('mpl/Hong Kong', 'mpl/Hong Kong'),\n", " ('mpl/Hungary', 'mpl/Hungary'),\n", " ('mpl/Iceland', 'mpl/Iceland'),\n", " ('mpl/India', 'mpl/India'),\n", " ('mpl/Indonesia', 'mpl/Indonesia'),\n", " ('mpl/Iran', 'mpl/Iran'),\n", " ('mpl/Iraq', 'mpl/Iraq'),\n", " ('mpl/Ireland', 'mpl/Ireland'),\n", " ('mpl/Israel', 'mpl/Israel'),\n", " ('mpl/Italy', 'mpl/Italy'),\n", " ('mpl/Jamaica', 'mpl/Jamaica'),\n", " ('mpl/Japan', 'mpl/Japan'),\n", " ('mpl/Jordan', 'mpl/Jordan'),\n", " ('mpl/Kazakhstan', 'mpl/Kazakhstan'),\n", " ('mpl/Kenya', 'mpl/Kenya'),\n", " ('mpl/Kiribati', 'mpl/Kiribati'),\n", " ('mpl/Korea, North', 'mpl/Korea, North'),\n", " ('mpl/Korea, South', 'mpl/Korea, South'),\n", " ('mpl/Kuwait', 'mpl/Kuwait'),\n", " ('mpl/Kyrgyzstan', 'mpl/Kyrgyzstan'),\n", " ('mpl/Laos', 'mpl/Laos'),\n", " ('mpl/Latvia', 'mpl/Latvia'),\n", " ('mpl/Lebanon', 'mpl/Lebanon'),\n", " ('mpl/Lesotho', 'mpl/Lesotho'),\n", " ('mpl/Liberia', 'mpl/Liberia'),\n", " ('mpl/Libya', 'mpl/Libya'),\n", " ('mpl/Lithuania', 'mpl/Lithuania'),\n", " ('mpl/Luxembourg', 'mpl/Luxembourg'),\n", " ('mpl/Macau', 'mpl/Macau'),\n", " ('mpl/Macedonia', 'mpl/Macedonia'),\n", " ('mpl/Madagascar', 'mpl/Madagascar'),\n", " ('mpl/Malawi', 'mpl/Malawi'),\n", " ('mpl/Malaysia', 'mpl/Malaysia'),\n", " ('mpl/Maldives', 'mpl/Maldives'),\n", " ('mpl/Mali', 'mpl/Mali'),\n", " ('mpl/Malta', 'mpl/Malta'),\n", " ('mpl/Martinique', 'mpl/Martinique'),\n", " ('mpl/Mauritania', 'mpl/Mauritania'),\n", " ('mpl/Mauritius', 'mpl/Mauritius'),\n", " ('mpl/Mexico', 'mpl/Mexico'),\n", " ('mpl/Middle East', 'mpl/Middle East'),\n", " ('mpl/Moldova', 'mpl/Moldova'),\n", " ('mpl/Mongolia', 'mpl/Mongolia'),\n", " ('mpl/Montenegro', 'mpl/Montenegro'),\n", " ('mpl/Montserrat', 'mpl/Montserrat'),\n", " ('mpl/Morocco', 'mpl/Morocco'),\n", " ('mpl/Mozambique', 'mpl/Mozambique'),\n", " ('mpl/Namibia', 'mpl/Namibia'),\n", " ('mpl/Nauru', 'mpl/Nauru'),\n", " ('mpl/Nepal', 'mpl/Nepal'),\n", " ('mpl/Netherlands', 'mpl/Netherlands'),\n", " ('mpl/Netherlands Antilles', 'mpl/Netherlands Antilles'),\n", " ('mpl/New Caledonia', 'mpl/New Caledonia'),\n", " ('mpl/New Zealand', 'mpl/New Zealand'),\n", " ('mpl/Nicaragua', 'mpl/Nicaragua'),\n", " ('mpl/Niger', 'mpl/Niger'),\n", " ('mpl/Nigeria', 'mpl/Nigeria'),\n", " ('mpl/Niue', 'mpl/Niue'),\n", " ('mpl/North America', 'mpl/North America'),\n", " ('mpl/Norway', 'mpl/Norway'),\n", " ('mpl/Oman', 'mpl/Oman'),\n", " ('mpl/Pakistan', 'mpl/Pakistan'),\n", " ('mpl/Palestine', 'mpl/Palestine'),\n", " ('mpl/Panama', 'mpl/Panama'),\n", " ('mpl/Papua New Guinea', 'mpl/Papua New Guinea'),\n", " ('mpl/Paraguay', 'mpl/Paraguay'),\n", " ('mpl/Peru', 'mpl/Peru'),\n", " ('mpl/Philippines', 'mpl/Philippines'),\n", " ('mpl/Poland', 'mpl/Poland'),\n", " ('mpl/Portugal', 'mpl/Portugal'),\n", " ('mpl/Puerto Rico', 'mpl/Puerto Rico'),\n", " ('mpl/Qatar', 'mpl/Qatar'),\n", " ('mpl/Reunion', 'mpl/Reunion'),\n", " ('mpl/Romania', 'mpl/Romania'),\n", " ('mpl/Russia', 'mpl/Russia'),\n", " ('mpl/Rwanda', 'mpl/Rwanda'),\n", " ('mpl/Saint Helena', 'mpl/Saint Helena'),\n", " ('mpl/Saint Kitts and Nevis', 'mpl/Saint Kitts and Nevis'),\n", " ('mpl/Saint Lucia', 'mpl/Saint Lucia'),\n", " ('mpl/Saint Pierre and Miquelon', 'mpl/Saint Pierre and Miquelon'),\n", " ('mpl/Saint Vincent/Grenadines', 'mpl/Saint Vincent/Grenadines'),\n", " ('mpl/Samoa', 'mpl/Samoa'),\n", " ('mpl/Sao Tome and Principe', 'mpl/Sao Tome and Principe'),\n", " ('mpl/Saudi Arabia', 'mpl/Saudi Arabia'),\n", " ('mpl/Senegal', 'mpl/Senegal'),\n", " ('mpl/Serbia', 'mpl/Serbia'),\n", " ('mpl/Seychelles', 'mpl/Seychelles'),\n", " ('mpl/Sierra Leone', 'mpl/Sierra Leone'),\n", " ('mpl/Singapore', 'mpl/Singapore'),\n", " ('mpl/Slovakia', 'mpl/Slovakia'),\n", " ('mpl/Slovenia', 'mpl/Slovenia'),\n", " ('mpl/Solomon Islands', 'mpl/Solomon Islands'),\n", " ('mpl/Somalia', 'mpl/Somalia'),\n", " ('mpl/South Africa', 'mpl/South Africa'),\n", " ('mpl/Spain', 'mpl/Spain'),\n", " ('mpl/Sri Lanka', 'mpl/Sri Lanka'),\n", " ('mpl/Sudan', 'mpl/Sudan'),\n", " ('mpl/Suriname', 'mpl/Suriname'),\n", " ('mpl/Swaziland', 'mpl/Swaziland'),\n", " ('mpl/Sweden', 'mpl/Sweden'),\n", " ('mpl/Switzerland', 'mpl/Switzerland'),\n", " ('mpl/Syria', 'mpl/Syria'),\n", " ('mpl/Taiwan', 'mpl/Taiwan'),\n", " ('mpl/Tajikistan', 'mpl/Tajikistan'),\n", " ('mpl/Tanzania', 'mpl/Tanzania'),\n", " ('mpl/Thailand', 'mpl/Thailand'),\n", " ('mpl/Timor-Leste (East Timor)', 'mpl/Timor-Leste (East Timor)'),\n", " ('mpl/Togo', 'mpl/Togo'),\n", " ('mpl/Tonga', 'mpl/Tonga'),\n", " ('mpl/Trinidad and Tobago', 'mpl/Trinidad and Tobago'),\n", " ('mpl/Tunisia', 'mpl/Tunisia'),\n", " ('mpl/Turkey', 'mpl/Turkey'),\n", " ('mpl/Turkmenistan', 'mpl/Turkmenistan'),\n", " ('mpl/Turks and Caicos Islands', 'mpl/Turks and Caicos Islands'),\n", " ('mpl/U.S. Pacific Islands', 'mpl/U.S. Pacific Islands'),\n", " ('mpl/Uganda', 'mpl/Uganda'),\n", " ('mpl/Ukraine', 'mpl/Ukraine'),\n", " ('mpl/United Arab Emirates', 'mpl/United Arab Emirates'),\n", " ('mpl/United Kingdom', 'mpl/United Kingdom'),\n", " ('mpl/United States', 'mpl/United States'),\n", " ('mpl/Uruguay', 'mpl/Uruguay'),\n", " ('mpl/Uzbekistan', 'mpl/Uzbekistan'),\n", " ('mpl/Vanuatu', 'mpl/Vanuatu'),\n", " ('mpl/Venezuela', 'mpl/Venezuela'),\n", " ('mpl/Vietnam', 'mpl/Vietnam'),\n", " ('mpl/Virgin Islands, U.S.', 'mpl/Virgin Islands, U.S.'),\n", " ('mpl/Virgin Islands, British', 'mpl/Virgin Islands, British'),\n", " ('mpl/Wake Island', 'mpl/Wake Island'),\n", " ('mpl/Western Sahara', 'mpl/Western Sahara'),\n", " ('mpl/World', 'mpl/World'),\n", " ('mpl/Yemen', 'mpl/Yemen'),\n", " ('mpl/Zambia', 'mpl/Zambia'),\n", " ('mpl/Zimbabwe', 'mpl/Zimbabwe')]" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "list(zip(items, items))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "from bokeh.charts import Line, show\n", "from bokeh.plotting import figure" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "from bokeh.io import output_notebook" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " Loading BokehJS ...\n", "
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "(function(global) {\n", " function now() {\n", " return new Date();\n", " }\n", "\n", " var force = true;\n", "\n", " if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n", " window._bokeh_onload_callbacks = [];\n", " window._bokeh_is_loading = undefined;\n", " }\n", "\n", "\n", " \n", " if (typeof (window._bokeh_timeout) === \"undefined\" || force === true) {\n", " window._bokeh_timeout = Date.now() + 5000;\n", " window._bokeh_failed_load = false;\n", " }\n", "\n", " var NB_LOAD_WARNING = {'data': {'text/html':\n", " \"
\\n\"+\n", " \"

\\n\"+\n", " \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n", " \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n", " \"

\\n\"+\n", " \"
    \\n\"+\n", " \"
  • re-rerun `output_notebook()` to attempt to load from CDN again, or
  • \\n\"+\n", " \"
  • use INLINE resources instead, as so:
  • \\n\"+\n", " \"
\\n\"+\n", " \"\\n\"+\n", " \"from bokeh.resources import INLINE\\n\"+\n", " \"output_notebook(resources=INLINE)\\n\"+\n", " \"\\n\"+\n", " \"
\"}};\n", "\n", " function display_loaded() {\n", " if (window.Bokeh !== undefined) {\n", " var el = document.getElementById(\"aa65fd43-0e8c-4886-87fb-20b38db331b8\");\n", " el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n", " } else if (Date.now() < window._bokeh_timeout) {\n", " setTimeout(display_loaded, 100)\n", " }\n", " }\n", "\n", " function run_callbacks() {\n", " window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n", " delete window._bokeh_onload_callbacks\n", " console.info(\"Bokeh: all callbacks have finished\");\n", " }\n", "\n", " function load_libs(js_urls, callback) {\n", " window._bokeh_onload_callbacks.push(callback);\n", " if (window._bokeh_is_loading > 0) {\n", " console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n", " return null;\n", " }\n", " if (js_urls == null || js_urls.length === 0) {\n", " run_callbacks();\n", " return null;\n", " }\n", " console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n", " window._bokeh_is_loading = js_urls.length;\n", " for (var i = 0; i < js_urls.length; i++) {\n", " var url = js_urls[i];\n", " var s = document.createElement('script');\n", " s.src = url;\n", " s.async = false;\n", " s.onreadystatechange = s.onload = function() {\n", " window._bokeh_is_loading--;\n", " if (window._bokeh_is_loading === 0) {\n", " console.log(\"Bokeh: all BokehJS libraries loaded\");\n", " run_callbacks()\n", " }\n", " };\n", " s.onerror = function() {\n", " console.warn(\"failed to load library \" + url);\n", " };\n", " console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", " document.getElementsByTagName(\"head\")[0].appendChild(s);\n", " }\n", " };var element = document.getElementById(\"aa65fd43-0e8c-4886-87fb-20b38db331b8\");\n", " if (element == null) {\n", " console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'aa65fd43-0e8c-4886-87fb-20b38db331b8' but no matching script tag was found. \")\n", " return false;\n", " }\n", "\n", " var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.js\"];\n", "\n", " var inline_js = [\n", " function(Bokeh) {\n", " Bokeh.set_log_level(\"info\");\n", " },\n", " \n", " function(Bokeh) {\n", " \n", " },\n", " \n", " function(Bokeh) {\n", " \n", " document.getElementById(\"aa65fd43-0e8c-4886-87fb-20b38db331b8\").textContent = \"BokehJS is loading...\";\n", " },\n", " function(Bokeh) {\n", " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.css\");\n", " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.css\");\n", " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.css\");\n", " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.5.min.css\");\n", " }\n", " ];\n", "\n", " function run_inline_js() {\n", " \n", " if ((window.Bokeh !== undefined) || (force === true)) {\n", " for (var i = 0; i < inline_js.length; i++) {\n", " inline_js[i](window.Bokeh);\n", " }if (force === true) {\n", " display_loaded();\n", " }} else if (Date.now() < window._bokeh_timeout) {\n", " setTimeout(run_inline_js, 100);\n", " } else if (!window._bokeh_failed_load) {\n", " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", " window._bokeh_failed_load = true;\n", " } else if (force !== true) {\n", " var cell = $(document.getElementById(\"aa65fd43-0e8c-4886-87fb-20b38db331b8\")).parents('.cell').data().cell;\n", " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", " }\n", "\n", " }\n", "\n", " if (window._bokeh_is_loading === 0) {\n", " console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n", " run_inline_js();\n", " } else {\n", " load_libs(js_urls, function() {\n", " console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n", " run_inline_js();\n", " });\n", " }\n", "}(this));" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "output_notebook()" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "p = figure(title=nations[1], logo=None, tools=\"box_zoom,pan,wheel_zoom,reset\",)\n", "p.line(x=df2[nations[1]].index, y=df2[nations[1]].values)\n", "# p.title(nations[1])\n", "show(p)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 41, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from bokeh.embed import components" ] }, { "cell_type": "code", "execution_count": 42, "metadata": { "collapsed": true }, "outputs": [], "source": [ "script, div = components(line)" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n" ] } ], "source": [ "print(script)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "
\n", "
\n", "
\n" ] } ], "source": [ "print(div)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import json" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "id_pos = script.find('elementid\":\"') + 12\n", "divid = script[id_pos:id_pos+36]\n", "script = script.replace(divid, 'bokeh-line')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(script)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x_start = script.find('\"x_values\":') + 11\n", "x_end = script.find(',\"y_values\":')\n", "y_start = script.find('\"y_values\":') + 11\n", "y_end = script[y_start:].find('}}') + y_start\n", "\n", "script = script.replace(script[x_start:x_end], 'newXvalues')\n", "script = script.replace(script[y_start:y_end], 'newYvalues')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "len('\"y_values\":')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "script[y_start:].find('}}') + y_start" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import bokeh" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'0.12.5'" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bokeh.__version__" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python [default]", "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.6.1" } }, "nbformat": 4, "nbformat_minor": 2 }