{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Choropleth Maps" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import plotly.plotly as py" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/vnd.plotly.v1+html": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "init_notebook_mode(connected=True)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# USA Data \n", "data = dict(type = 'choropleth', \n", " locations =['AZ', 'CA', 'NY'],\n", " locationmode = 'USA-states',\n", " colorscale ='Greens',\n", " text = ['Arizona', 'Cali', 'New York'],\n", " z = [1.0, 2.0, 3.0],\n", " colorbar = {'title':'Colorbar Title Goes Here'})" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'colorbar': {'title': 'Colorbar Title Goes Here'},\n", " 'colorscale': 'Greens',\n", " 'locationmode': 'USA-states',\n", " 'locations': ['AZ', 'CA', 'NY'],\n", " 'text': ['Arizona', 'Cali', 'New York'],\n", " 'type': 'choropleth',\n", " 'z': [1.0, 2.0, 3.0]}" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# layout object\n", "layout = dict(geo = {'scope': 'usa'})" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import plotly.graph_objs as go" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": true }, "outputs": [], "source": [ "choromap = go.Figure(data = [data], layout=layout)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "scrolled": true }, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "data": [ { "colorbar": { "title": "Colorbar Title Goes Here" }, "colorscale": "Greens", "locationmode": "USA-states", "locations": [ "AZ", "CA", "NY" ], "text": [ "Arizona", "Cali", "New York" ], "type": "choropleth", "z": [ 1, 2, 3 ] } ], "layout": { "geo": { "scope": "usa" } } }, "text/html": [ "
" ], "text/vnd.plotly.v1+html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "iplot(choromap)" ] }, { "cell_type": "code", "execution_count": 10, "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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \n", " \n", " \n", "
codestatecategorytotal exportsbeefporkpoultrydairyfruits freshfruits proctotal fruitsveggies freshveggies proctotal veggiescornwheatcottontext
0ALAlabamastate1390.6334.410.6481.04.068.017.125.115.58.914.3334.970.0317.61Alabama<br>Beef 34.4 Dairy 4.06<br>Fruits 25.1...
1AKAlaskastate13.310.20.10.00.190.00.00.000.61.01.560.00.00.00Alaska<br>Beef 0.2 Dairy 0.19<br>Fruits 0.0 Ve...
2AZArizonastate1463.1771.317.90.0105.4819.341.060.27147.5239.4386.917.348.7423.95Arizona<br>Beef 71.3 Dairy 105.48<br>Fruits 60...
3ARArkansasstate3586.0253.229.4562.93.532.24.76.884.47.111.4569.5114.5665.44Arkansas<br>Beef 53.2 Dairy 3.53<br>Fruits 6.8...
4CACaliforniastate16472.88228.711.1225.4929.952791.85944.68736.40803.21303.52106.7934.6249.31064.95California<br>Beef 228.7 Dairy 929.95<br>Frui...
5COColoradostate1851.33261.466.014.071.945.712.217.9945.173.2118.27183.2400.50.00Colorado<br>Beef 261.4 Dairy 71.94<br>Fruits 1...
6CTConnecticutstate259.621.10.16.99.494.28.913.104.36.911.160.00.00.00Connecticut<br>Beef 1.1 Dairy 9.49<br>Fruits 1...
7DEDelawarestate282.190.40.6114.72.300.51.01.537.612.420.0326.922.90.00Delaware<br>Beef 0.4 Dairy 2.3<br>Fruits 1.53 ...
8FLFloridastate3764.0942.60.956.966.31438.2933.11371.36171.9279.0450.863.51.878.24Florida<br>Beef 42.6 Dairy 66.31<br>Fruits 137...
9GAGeorgiastate2860.8431.018.9630.438.3874.6158.9233.5159.095.8154.7757.865.41154.07Georgia<br>Beef 31.0 Dairy 38.38<br>Fruits 233...
10HIHawaiistate401.844.00.71.31.1617.737.855.519.515.424.830.00.00.00Hawaii<br>Beef 4.0 Dairy 1.16<br>Fruits 55.51 ...
11IDIdahostate2078.89119.80.02.4294.606.914.721.64121.7197.5319.1924.0568.20.00Idaho<br>Beef 119.8 Dairy 294.6<br>Fruits 21.6...
12ILIllinoisstate8709.4853.7394.014.045.824.08.512.5315.224.739.952228.5223.80.00Illinois<br>Beef 53.7 Dairy 45.82<br>Fruits 12...
13INIndianastate5050.2321.9341.9165.689.704.18.812.9814.423.437.891123.2114.00.00Indiana<br>Beef 21.9 Dairy 89.7<br>Fruits 12.9...
14IAIowastate11273.76289.81895.6155.6107.001.02.23.242.74.47.102529.83.10.00Iowa<br>Beef 289.8 Dairy 107.0<br>Fruits 3.24 ...
15KSKansasstate4589.01659.3179.46.465.451.02.13.113.65.89.32457.31426.543.98Kansas<br>Beef 659.3 Dairy 65.45<br>Fruits 3.1...
16KYKentuckystate1889.1554.834.2151.328.272.14.56.600.00.00.00179.1149.30.00Kentucky<br>Beef 54.8 Dairy 28.27<br>Fruits 6....
17LALouisianastate1914.2319.80.877.26.025.712.117.836.610.717.2591.478.7280.42Louisiana<br>Beef 19.8 Dairy 6.02<br>Fruits 17...
18MEMainestate278.371.40.510.416.1816.635.452.0124.038.962.900.00.00.00Maine<br>Beef 1.4 Dairy 16.18<br>Fruits 52.01 ...
19MDMarylandstate692.755.63.1127.024.814.18.812.907.812.620.4354.155.80.00Maryland<br>Beef 5.6 Dairy 24.81<br>Fruits 12....
20MAMassachusettsstate248.650.60.50.65.8125.855.080.838.113.121.130.00.00.00Massachusetts<br>Beef 0.6 Dairy 5.81<br>Fruits...
21MIMichiganstate3164.1637.7118.132.6214.8282.3175.3257.6972.4117.5189.96381.5247.00.00Michigan<br>Beef 37.7 Dairy 214.82<br>Fruits 2...
22MNMinnesotastate7192.33112.3740.4189.2218.052.55.47.9145.974.5120.371264.3538.10.00Minnesota<br>Beef 112.3 Dairy 218.05<br>Fruits...
23MSMississippistate2170.8012.830.4370.85.455.411.617.0410.617.227.87110.0102.2494.75Mississippi<br>Beef 12.8 Dairy 5.45<br>Fruits ...
24MOMissouristate3933.42137.2277.3196.134.264.29.013.186.811.117.90428.8161.7345.29Missouri<br>Beef 137.2 Dairy 34.26<br>Fruits 1...
25MTMontanastate1718.00105.016.71.76.821.12.23.3017.328.045.275.41198.10.00Montana<br>Beef 105.0 Dairy 6.82<br>Fruits 3.3...
26NENebraskastate7114.13762.2262.531.430.070.71.52.1620.433.153.501735.9292.30.00Nebraska<br>Beef 762.2 Dairy 30.07<br>Fruits 2...
27NVNevadastate139.8921.80.20.016.570.40.81.1910.617.327.930.05.40.00Nevada<br>Beef 21.8 Dairy 16.57<br>Fruits 1.19...
28NHNew Hampshirestate73.060.60.20.87.462.65.47.981.72.84.500.00.00.00New Hampshire<br>Beef 0.6 Dairy 7.46<br>Fruits...
29NJNew Jerseystate500.400.80.44.63.3735.074.5109.4521.635.056.5410.16.70.00New Jersey<br>Beef 0.8 Dairy 3.37<br>Fruits 10...
30NMNew Mexicostate751.58117.20.10.3191.0132.669.3101.9016.727.143.8811.213.972.62New Mexico<br>Beef 117.2 Dairy 191.01<br>Fruit...
31NYNew Yorkstate1488.9022.25.817.7331.8064.7137.8202.5654.788.7143.37106.129.90.00New York<br>Beef 22.2 Dairy 331.8<br>Fruits 20...
32NCNorth Carolinastate3806.0524.8702.8598.424.9023.850.774.4757.493.1150.4592.2200.3470.86North Carolina<br>Beef 24.8 Dairy 24.9<br>Frui...
33NDNorth Dakotastate3761.9678.516.10.58.140.10.20.2549.980.9130.79236.11664.50.00North Dakota<br>Beef 78.5 Dairy 8.14<br>Fruits...
34OHOhiostate3979.7936.2199.1129.9134.578.718.527.2120.433.153.53535.1207.40.00Ohio<br>Beef 36.2 Dairy 134.57<br>Fruits 27.21...
35OKOklahomastate1646.41337.6265.3131.124.353.06.39.243.45.58.9027.5324.8110.54Oklahoma<br>Beef 337.6 Dairy 24.35<br>Fruits 9...
36OROregonstate1794.5758.81.414.263.66100.7214.4315.0448.278.3126.5011.7320.30.00Oregon<br>Beef 58.8 Dairy 63.66<br>Fruits 315....
37PAPennsylvaniastate1969.8750.991.3169.8280.8728.660.989.4814.623.738.26112.141.00.00Pennsylvania<br>Beef 50.9 Dairy 280.87<br>Frui...
38RIRhode Islandstate31.590.10.10.20.520.91.92.831.21.93.020.00.00.00Rhode Island<br>Beef 0.1 Dairy 0.52<br>Fruits ...
39SCSouth Carolinastate929.9315.210.9186.57.6217.136.453.4516.326.442.6632.155.3206.10South Carolina<br>Beef 15.2 Dairy 7.62<br>Frui...
40SDSouth Dakotastate3770.19193.5160.229.346.770.30.50.801.52.54.06643.6704.50.00South Dakota<br>Beef 193.5 Dairy 46.77<br>Frui...
41TNTennesseestate1535.1351.117.682.421.182.04.26.239.415.324.6788.8100.0363.83Tennessee<br>Beef 51.1 Dairy 21.18<br>Fruits 6...
42TXTexasstate6648.22961.042.7339.2240.5531.968.099.9043.971.3115.23167.2309.72308.76Texas<br>Beef 961.0 Dairy 240.55<br>Fruits 99....
43UTUtahstate453.3927.959.023.148.603.98.412.342.54.16.605.342.80.00Utah<br>Beef 27.9 Dairy 48.6<br>Fruits 12.34 V...
44VTVermontstate180.146.20.20.965.982.65.48.011.52.54.050.00.00.00Vermont<br>Beef 6.2 Dairy 65.98<br>Fruits 8.01...
45VAVirginiastate1146.4839.516.9164.747.8511.724.836.4810.416.927.2539.577.564.84Virginia<br>Beef 39.5 Dairy 47.85<br>Fruits 36...
46WAWashingtonstate3894.8159.20.035.6154.18555.61183.01738.57138.7225.1363.7929.5786.30.00Washington<br>Beef 59.2 Dairy 154.18<br>Fruits...
47WVWest Virginiastate138.8912.00.345.43.903.77.911.540.00.00.003.51.60.00West Virginia<br>Beef 12.0 Dairy 3.9<br>Fruits...
48WIWisconsinstate3090.23107.338.634.5633.6042.891.0133.8056.892.2148.99460.596.70.00Wisconsin<br>Beef 107.3 Dairy 633.6<br>Fruits ...
49WYWyomingstate349.6975.133.20.12.890.10.10.173.96.310.239.020.70.00Wyoming<br>Beef 75.1 Dairy 2.89<br>Fruits 0.17...
\n", "
" ], "text/plain": [ " code state category total exports beef pork poultry \\\n", "0 AL Alabama state 1390.63 34.4 10.6 481.0 \n", "1 AK Alaska state 13.31 0.2 0.1 0.0 \n", "2 AZ Arizona state 1463.17 71.3 17.9 0.0 \n", "3 AR Arkansas state 3586.02 53.2 29.4 562.9 \n", "4 CA California state 16472.88 228.7 11.1 225.4 \n", "5 CO Colorado state 1851.33 261.4 66.0 14.0 \n", "6 CT Connecticut state 259.62 1.1 0.1 6.9 \n", "7 DE Delaware state 282.19 0.4 0.6 114.7 \n", "8 FL Florida state 3764.09 42.6 0.9 56.9 \n", "9 GA Georgia state 2860.84 31.0 18.9 630.4 \n", "10 HI Hawaii state 401.84 4.0 0.7 1.3 \n", "11 ID Idaho state 2078.89 119.8 0.0 2.4 \n", "12 IL Illinois state 8709.48 53.7 394.0 14.0 \n", "13 IN Indiana state 5050.23 21.9 341.9 165.6 \n", "14 IA Iowa state 11273.76 289.8 1895.6 155.6 \n", "15 KS Kansas state 4589.01 659.3 179.4 6.4 \n", "16 KY Kentucky state 1889.15 54.8 34.2 151.3 \n", "17 LA Louisiana state 1914.23 19.8 0.8 77.2 \n", "18 ME Maine state 278.37 1.4 0.5 10.4 \n", "19 MD Maryland state 692.75 5.6 3.1 127.0 \n", "20 MA Massachusetts state 248.65 0.6 0.5 0.6 \n", "21 MI Michigan state 3164.16 37.7 118.1 32.6 \n", "22 MN Minnesota state 7192.33 112.3 740.4 189.2 \n", "23 MS Mississippi state 2170.80 12.8 30.4 370.8 \n", "24 MO Missouri state 3933.42 137.2 277.3 196.1 \n", "25 MT Montana state 1718.00 105.0 16.7 1.7 \n", "26 NE Nebraska state 7114.13 762.2 262.5 31.4 \n", "27 NV Nevada state 139.89 21.8 0.2 0.0 \n", "28 NH New Hampshire state 73.06 0.6 0.2 0.8 \n", "29 NJ New Jersey state 500.40 0.8 0.4 4.6 \n", "30 NM New Mexico state 751.58 117.2 0.1 0.3 \n", "31 NY New York state 1488.90 22.2 5.8 17.7 \n", "32 NC North Carolina state 3806.05 24.8 702.8 598.4 \n", "33 ND North Dakota state 3761.96 78.5 16.1 0.5 \n", "34 OH Ohio state 3979.79 36.2 199.1 129.9 \n", "35 OK Oklahoma state 1646.41 337.6 265.3 131.1 \n", "36 OR Oregon state 1794.57 58.8 1.4 14.2 \n", "37 PA Pennsylvania state 1969.87 50.9 91.3 169.8 \n", "38 RI Rhode Island state 31.59 0.1 0.1 0.2 \n", "39 SC South Carolina state 929.93 15.2 10.9 186.5 \n", "40 SD South Dakota state 3770.19 193.5 160.2 29.3 \n", "41 TN Tennessee state 1535.13 51.1 17.6 82.4 \n", "42 TX Texas state 6648.22 961.0 42.7 339.2 \n", "43 UT Utah state 453.39 27.9 59.0 23.1 \n", "44 VT Vermont state 180.14 6.2 0.2 0.9 \n", "45 VA Virginia state 1146.48 39.5 16.9 164.7 \n", "46 WA Washington state 3894.81 59.2 0.0 35.6 \n", "47 WV West Virginia state 138.89 12.0 0.3 45.4 \n", "48 WI Wisconsin state 3090.23 107.3 38.6 34.5 \n", "49 WY Wyoming state 349.69 75.1 33.2 0.1 \n", "\n", " dairy fruits fresh fruits proc total fruits veggies fresh \\\n", "0 4.06 8.0 17.1 25.11 5.5 \n", "1 0.19 0.0 0.0 0.00 0.6 \n", "2 105.48 19.3 41.0 60.27 147.5 \n", "3 3.53 2.2 4.7 6.88 4.4 \n", "4 929.95 2791.8 5944.6 8736.40 803.2 \n", "5 71.94 5.7 12.2 17.99 45.1 \n", "6 9.49 4.2 8.9 13.10 4.3 \n", "7 2.30 0.5 1.0 1.53 7.6 \n", "8 66.31 438.2 933.1 1371.36 171.9 \n", "9 38.38 74.6 158.9 233.51 59.0 \n", "10 1.16 17.7 37.8 55.51 9.5 \n", "11 294.60 6.9 14.7 21.64 121.7 \n", "12 45.82 4.0 8.5 12.53 15.2 \n", "13 89.70 4.1 8.8 12.98 14.4 \n", "14 107.00 1.0 2.2 3.24 2.7 \n", "15 65.45 1.0 2.1 3.11 3.6 \n", "16 28.27 2.1 4.5 6.60 0.0 \n", "17 6.02 5.7 12.1 17.83 6.6 \n", "18 16.18 16.6 35.4 52.01 24.0 \n", "19 24.81 4.1 8.8 12.90 7.8 \n", "20 5.81 25.8 55.0 80.83 8.1 \n", "21 214.82 82.3 175.3 257.69 72.4 \n", "22 218.05 2.5 5.4 7.91 45.9 \n", "23 5.45 5.4 11.6 17.04 10.6 \n", "24 34.26 4.2 9.0 13.18 6.8 \n", "25 6.82 1.1 2.2 3.30 17.3 \n", "26 30.07 0.7 1.5 2.16 20.4 \n", "27 16.57 0.4 0.8 1.19 10.6 \n", "28 7.46 2.6 5.4 7.98 1.7 \n", "29 3.37 35.0 74.5 109.45 21.6 \n", "30 191.01 32.6 69.3 101.90 16.7 \n", "31 331.80 64.7 137.8 202.56 54.7 \n", "32 24.90 23.8 50.7 74.47 57.4 \n", "33 8.14 0.1 0.2 0.25 49.9 \n", "34 134.57 8.7 18.5 27.21 20.4 \n", "35 24.35 3.0 6.3 9.24 3.4 \n", "36 63.66 100.7 214.4 315.04 48.2 \n", "37 280.87 28.6 60.9 89.48 14.6 \n", "38 0.52 0.9 1.9 2.83 1.2 \n", "39 7.62 17.1 36.4 53.45 16.3 \n", "40 46.77 0.3 0.5 0.80 1.5 \n", "41 21.18 2.0 4.2 6.23 9.4 \n", "42 240.55 31.9 68.0 99.90 43.9 \n", "43 48.60 3.9 8.4 12.34 2.5 \n", "44 65.98 2.6 5.4 8.01 1.5 \n", "45 47.85 11.7 24.8 36.48 10.4 \n", "46 154.18 555.6 1183.0 1738.57 138.7 \n", "47 3.90 3.7 7.9 11.54 0.0 \n", "48 633.60 42.8 91.0 133.80 56.8 \n", "49 2.89 0.1 0.1 0.17 3.9 \n", "\n", " veggies proc total veggies corn wheat cotton \\\n", "0 8.9 14.33 34.9 70.0 317.61 \n", "1 1.0 1.56 0.0 0.0 0.00 \n", "2 239.4 386.91 7.3 48.7 423.95 \n", "3 7.1 11.45 69.5 114.5 665.44 \n", "4 1303.5 2106.79 34.6 249.3 1064.95 \n", "5 73.2 118.27 183.2 400.5 0.00 \n", "6 6.9 11.16 0.0 0.0 0.00 \n", "7 12.4 20.03 26.9 22.9 0.00 \n", "8 279.0 450.86 3.5 1.8 78.24 \n", "9 95.8 154.77 57.8 65.4 1154.07 \n", "10 15.4 24.83 0.0 0.0 0.00 \n", "11 197.5 319.19 24.0 568.2 0.00 \n", "12 24.7 39.95 2228.5 223.8 0.00 \n", "13 23.4 37.89 1123.2 114.0 0.00 \n", "14 4.4 7.10 2529.8 3.1 0.00 \n", "15 5.8 9.32 457.3 1426.5 43.98 \n", "16 0.0 0.00 179.1 149.3 0.00 \n", "17 10.7 17.25 91.4 78.7 280.42 \n", "18 38.9 62.90 0.0 0.0 0.00 \n", "19 12.6 20.43 54.1 55.8 0.00 \n", "20 13.1 21.13 0.0 0.0 0.00 \n", "21 117.5 189.96 381.5 247.0 0.00 \n", "22 74.5 120.37 1264.3 538.1 0.00 \n", "23 17.2 27.87 110.0 102.2 494.75 \n", "24 11.1 17.90 428.8 161.7 345.29 \n", "25 28.0 45.27 5.4 1198.1 0.00 \n", "26 33.1 53.50 1735.9 292.3 0.00 \n", "27 17.3 27.93 0.0 5.4 0.00 \n", "28 2.8 4.50 0.0 0.0 0.00 \n", "29 35.0 56.54 10.1 6.7 0.00 \n", "30 27.1 43.88 11.2 13.9 72.62 \n", "31 88.7 143.37 106.1 29.9 0.00 \n", "32 93.1 150.45 92.2 200.3 470.86 \n", "33 80.9 130.79 236.1 1664.5 0.00 \n", "34 33.1 53.53 535.1 207.4 0.00 \n", "35 5.5 8.90 27.5 324.8 110.54 \n", "36 78.3 126.50 11.7 320.3 0.00 \n", "37 23.7 38.26 112.1 41.0 0.00 \n", "38 1.9 3.02 0.0 0.0 0.00 \n", "39 26.4 42.66 32.1 55.3 206.10 \n", "40 2.5 4.06 643.6 704.5 0.00 \n", "41 15.3 24.67 88.8 100.0 363.83 \n", "42 71.3 115.23 167.2 309.7 2308.76 \n", "43 4.1 6.60 5.3 42.8 0.00 \n", "44 2.5 4.05 0.0 0.0 0.00 \n", "45 16.9 27.25 39.5 77.5 64.84 \n", "46 225.1 363.79 29.5 786.3 0.00 \n", "47 0.0 0.00 3.5 1.6 0.00 \n", "48 92.2 148.99 460.5 96.7 0.00 \n", "49 6.3 10.23 9.0 20.7 0.00 \n", "\n", " text \n", "0 Alabama
Beef 34.4 Dairy 4.06
Fruits 25.1... \n", "1 Alaska
Beef 0.2 Dairy 0.19
Fruits 0.0 Ve... \n", "2 Arizona
Beef 71.3 Dairy 105.48
Fruits 60... \n", "3 Arkansas
Beef 53.2 Dairy 3.53
Fruits 6.8... \n", "4 California
Beef 228.7 Dairy 929.95
Frui... \n", "5 Colorado
Beef 261.4 Dairy 71.94
Fruits 1... \n", "6 Connecticut
Beef 1.1 Dairy 9.49
Fruits 1... \n", "7 Delaware
Beef 0.4 Dairy 2.3
Fruits 1.53 ... \n", "8 Florida
Beef 42.6 Dairy 66.31
Fruits 137... \n", "9 Georgia
Beef 31.0 Dairy 38.38
Fruits 233... \n", "10 Hawaii
Beef 4.0 Dairy 1.16
Fruits 55.51 ... \n", "11 Idaho
Beef 119.8 Dairy 294.6
Fruits 21.6... \n", "12 Illinois
Beef 53.7 Dairy 45.82
Fruits 12... \n", "13 Indiana
Beef 21.9 Dairy 89.7
Fruits 12.9... \n", "14 Iowa
Beef 289.8 Dairy 107.0
Fruits 3.24 ... \n", "15 Kansas
Beef 659.3 Dairy 65.45
Fruits 3.1... \n", "16 Kentucky
Beef 54.8 Dairy 28.27
Fruits 6.... \n", "17 Louisiana
Beef 19.8 Dairy 6.02
Fruits 17... \n", "18 Maine
Beef 1.4 Dairy 16.18
Fruits 52.01 ... \n", "19 Maryland
Beef 5.6 Dairy 24.81
Fruits 12.... \n", "20 Massachusetts
Beef 0.6 Dairy 5.81
Fruits... \n", "21 Michigan
Beef 37.7 Dairy 214.82
Fruits 2... \n", "22 Minnesota
Beef 112.3 Dairy 218.05
Fruits... \n", "23 Mississippi
Beef 12.8 Dairy 5.45
Fruits ... \n", "24 Missouri
Beef 137.2 Dairy 34.26
Fruits 1... \n", "25 Montana
Beef 105.0 Dairy 6.82
Fruits 3.3... \n", "26 Nebraska
Beef 762.2 Dairy 30.07
Fruits 2... \n", "27 Nevada
Beef 21.8 Dairy 16.57
Fruits 1.19... \n", "28 New Hampshire
Beef 0.6 Dairy 7.46
Fruits... \n", "29 New Jersey
Beef 0.8 Dairy 3.37
Fruits 10... \n", "30 New Mexico
Beef 117.2 Dairy 191.01
Fruit... \n", "31 New York
Beef 22.2 Dairy 331.8
Fruits 20... \n", "32 North Carolina
Beef 24.8 Dairy 24.9
Frui... \n", "33 North Dakota
Beef 78.5 Dairy 8.14
Fruits... \n", "34 Ohio
Beef 36.2 Dairy 134.57
Fruits 27.21... \n", "35 Oklahoma
Beef 337.6 Dairy 24.35
Fruits 9... \n", "36 Oregon
Beef 58.8 Dairy 63.66
Fruits 315.... \n", "37 Pennsylvania
Beef 50.9 Dairy 280.87
Frui... \n", "38 Rhode Island
Beef 0.1 Dairy 0.52
Fruits ... \n", "39 South Carolina
Beef 15.2 Dairy 7.62
Frui... \n", "40 South Dakota
Beef 193.5 Dairy 46.77
Frui... \n", "41 Tennessee
Beef 51.1 Dairy 21.18
Fruits 6... \n", "42 Texas
Beef 961.0 Dairy 240.55
Fruits 99.... \n", "43 Utah
Beef 27.9 Dairy 48.6
Fruits 12.34 V... \n", "44 Vermont
Beef 6.2 Dairy 65.98
Fruits 8.01... \n", "45 Virginia
Beef 39.5 Dairy 47.85
Fruits 36... \n", "46 Washington
Beef 59.2 Dairy 154.18
Fruits... \n", "47 West Virginia
Beef 12.0 Dairy 3.9
Fruits... \n", "48 Wisconsin
Beef 107.3 Dairy 633.6
Fruits ... \n", "49 Wyoming
Beef 75.1 Dairy 2.89
Fruits 0.17... " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "df = pd.read_csv('2011_US_AGRI_Exports')\n", "df" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": true }, "outputs": [], "source": [ "data = dict(type = 'choropleth', \n", " colorscale = 'YIOrRd',\n", " locations = df['code'],\n", " locationmode ='USA-states',\n", " z = df['total exports'], \n", " text = df['text'],\n", " marker = dict(line= dict(color = 'rgb(12, 12, 12)', width=4)),\n", " colorbar = {'title': 'Millions USD'}\n", " )" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": true }, "outputs": [], "source": [ "layout = dict(title = '2011 US Agriculture Exports by State',\n", " geo = dict(scope ='usa', showlakes=True, lakecolor = 'rgb(85, 173, 240)'))" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'geo': {'lakecolor': 'rgb(85, 173, 240)', 'scope': 'usa', 'showlakes': True},\n", " 'title': '2011 US Agriculture Exports by State'}" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "layout" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": true }, "outputs": [], "source": [ "choromap2 = go.Figure(data=[data], layout=layout)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "data": [ { "colorbar": { "title": "Millions USD" }, "colorscale": "YIOrRd", "locationmode": "USA-states", "locations": [ "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY" ], "marker": { "line": { "color": "rgb(12, 12, 12)", "width": 4 } }, "text": [ "Alabama
Beef 34.4 Dairy 4.06
Fruits 25.11 Veggies 14.33
Wheat 70.0 Corn 34.9", "Alaska
Beef 0.2 Dairy 0.19
Fruits 0.0 Veggies 1.56
Wheat 0.0 Corn 0.0", "Arizona
Beef 71.3 Dairy 105.48
Fruits 60.27 Veggies 386.91
Wheat 48.7 Corn 7.3", "Arkansas
Beef 53.2 Dairy 3.53
Fruits 6.88 Veggies 11.45
Wheat 114.5 Corn 69.5", " California
Beef 228.7 Dairy 929.95
Fruits 8736.4 Veggies 2106.79
Wheat 249.3 Corn 34.6", "Colorado
Beef 261.4 Dairy 71.94
Fruits 17.99 Veggies 118.27
Wheat 400.5 Corn 183.2", "Connecticut
Beef 1.1 Dairy 9.49
Fruits 13.1 Veggies 11.16
Wheat 0.0 Corn 0.0", "Delaware
Beef 0.4 Dairy 2.3
Fruits 1.53 Veggies 20.03
Wheat 22.9 Corn 26.9", "Florida
Beef 42.6 Dairy 66.31
Fruits 1371.36 Veggies 450.86
Wheat 1.8 Corn 3.5", "Georgia
Beef 31.0 Dairy 38.38
Fruits 233.51 Veggies 154.77
Wheat 65.4 Corn 57.8", "Hawaii
Beef 4.0 Dairy 1.16
Fruits 55.51 Veggies 24.83
Wheat 0.0 Corn 0.0", "Idaho
Beef 119.8 Dairy 294.6
Fruits 21.64 Veggies 319.19
Wheat 568.2 Corn 24.0", "Illinois
Beef 53.7 Dairy 45.82
Fruits 12.53 Veggies 39.95
Wheat 223.8 Corn 2228.5", "Indiana
Beef 21.9 Dairy 89.7
Fruits 12.98 Veggies 37.89
Wheat 114.0 Corn 1123.2", "Iowa
Beef 289.8 Dairy 107.0
Fruits 3.24 Veggies 7.1
Wheat 3.1 Corn 2529.8", "Kansas
Beef 659.3 Dairy 65.45
Fruits 3.11 Veggies 9.32
Wheat 1426.5 Corn 457.3", "Kentucky
Beef 54.8 Dairy 28.27
Fruits 6.6 Veggies 0.0
Wheat 149.3 Corn 179.1", "Louisiana
Beef 19.8 Dairy 6.02
Fruits 17.83 Veggies 17.25
Wheat 78.7 Corn 91.4", "Maine
Beef 1.4 Dairy 16.18
Fruits 52.01 Veggies 62.9
Wheat 0.0 Corn 0.0", "Maryland
Beef 5.6 Dairy 24.81
Fruits 12.9 Veggies 20.43
Wheat 55.8 Corn 54.1", "Massachusetts
Beef 0.6 Dairy 5.81
Fruits 80.83 Veggies 21.13
Wheat 0.0 Corn 0.0", "Michigan
Beef 37.7 Dairy 214.82
Fruits 257.69 Veggies 189.96
Wheat 247.0 Corn 381.5", "Minnesota
Beef 112.3 Dairy 218.05
Fruits 7.91 Veggies 120.37
Wheat 538.1 Corn 1264.3", "Mississippi
Beef 12.8 Dairy 5.45
Fruits 17.04 Veggies 27.87
Wheat 102.2 Corn 110.0", "Missouri
Beef 137.2 Dairy 34.26
Fruits 13.18 Veggies 17.9
Wheat 161.7 Corn 428.8", "Montana
Beef 105.0 Dairy 6.82
Fruits 3.3 Veggies 45.27
Wheat 1198.1 Corn 5.4", "Nebraska
Beef 762.2 Dairy 30.07
Fruits 2.16 Veggies 53.5
Wheat 292.3 Corn 1735.9", "Nevada
Beef 21.8 Dairy 16.57
Fruits 1.19 Veggies 27.93
Wheat 5.4 Corn 0.0", "New Hampshire
Beef 0.6 Dairy 7.46
Fruits 7.98 Veggies 4.5
Wheat 0.0 Corn 0.0", "New Jersey
Beef 0.8 Dairy 3.37
Fruits 109.45 Veggies 56.54
Wheat 6.7 Corn 10.1", "New Mexico
Beef 117.2 Dairy 191.01
Fruits 101.9 Veggies 43.88
Wheat 13.9 Corn 11.2", "New York
Beef 22.2 Dairy 331.8
Fruits 202.56 Veggies 143.37
Wheat 29.9 Corn 106.1", "North Carolina
Beef 24.8 Dairy 24.9
Fruits 74.47 Veggies 150.45
Wheat 200.3 Corn 92.2", "North Dakota
Beef 78.5 Dairy 8.14
Fruits 0.25 Veggies 130.79
Wheat 1664.5 Corn 236.1", "Ohio
Beef 36.2 Dairy 134.57
Fruits 27.21 Veggies 53.53
Wheat 207.4 Corn 535.1", "Oklahoma
Beef 337.6 Dairy 24.35
Fruits 9.24 Veggies 8.9
Wheat 324.8 Corn 27.5", "Oregon
Beef 58.8 Dairy 63.66
Fruits 315.04 Veggies 126.5
Wheat 320.3 Corn 11.7", "Pennsylvania
Beef 50.9 Dairy 280.87
Fruits 89.48 Veggies 38.26
Wheat 41.0 Corn 112.1", "Rhode Island
Beef 0.1 Dairy 0.52
Fruits 2.83 Veggies 3.02
Wheat 0.0 Corn 0.0", "South Carolina
Beef 15.2 Dairy 7.62
Fruits 53.45 Veggies 42.66
Wheat 55.3 Corn 32.1", "South Dakota
Beef 193.5 Dairy 46.77
Fruits 0.8 Veggies 4.06
Wheat 704.5 Corn 643.6", "Tennessee
Beef 51.1 Dairy 21.18
Fruits 6.23 Veggies 24.67
Wheat 100.0 Corn 88.8", "Texas
Beef 961.0 Dairy 240.55
Fruits 99.9 Veggies 115.23
Wheat 309.7 Corn 167.2", "Utah
Beef 27.9 Dairy 48.6
Fruits 12.34 Veggies 6.6
Wheat 42.8 Corn 5.3", "Vermont
Beef 6.2 Dairy 65.98
Fruits 8.01 Veggies 4.05
Wheat 0.0 Corn 0.0", "Virginia
Beef 39.5 Dairy 47.85
Fruits 36.48 Veggies 27.25
Wheat 77.5 Corn 39.5", "Washington
Beef 59.2 Dairy 154.18
Fruits 1738.57 Veggies 363.79
Wheat 786.3 Corn 29.5", "West Virginia
Beef 12.0 Dairy 3.9
Fruits 11.54 Veggies 0.0
Wheat 1.6 Corn 3.5", "Wisconsin
Beef 107.3 Dairy 633.6
Fruits 133.8 Veggies 148.99
Wheat 96.7 Corn 460.5", "Wyoming
Beef 75.1 Dairy 2.89
Fruits 0.17 Veggies 10.23
Wheat 20.7 Corn 9.0" ], "type": "choropleth", "z": [ 1390.63, 13.31, 1463.17, 3586.02, 16472.88, 1851.33, 259.62, 282.19, 3764.09, 2860.84, 401.84, 2078.89, 8709.48, 5050.23, 11273.76, 4589.01, 1889.15, 1914.23, 278.37, 692.75, 248.65, 3164.16, 7192.33, 2170.8, 3933.42, 1718, 7114.13, 139.89, 73.06, 500.4, 751.58, 1488.9, 3806.05, 3761.96, 3979.79, 1646.41, 1794.57, 1969.87, 31.59, 929.93, 3770.19, 1535.13, 6648.22, 453.39, 180.14, 1146.48, 3894.81, 138.89, 3090.23, 349.69 ] } ], "layout": { "geo": { "lakecolor": "rgb(85, 173, 240)", "scope": "usa", "showlakes": true }, "title": "2011 US Agriculture Exports by State" } }, "text/html": [ "
" ], "text/vnd.plotly.v1+html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "iplot(choromap2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "California had the highest export in 2011. Well, considering that I did see a lot of fruits and veggies coming from Cali in my local grocery stores." ] }, { "cell_type": "code", "execution_count": 16, "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", "
COUNTRYGDP (BILLIONS)CODE
0Afghanistan21.71AFG
1Albania13.40ALB
2Algeria227.80DZA
3American Samoa0.75ASM
4Andorra4.80AND
\n", "
" ], "text/plain": [ " COUNTRY GDP (BILLIONS) CODE\n", "0 Afghanistan 21.71 AFG\n", "1 Albania 13.40 ALB\n", "2 Algeria 227.80 DZA\n", "3 American Samoa 0.75 ASM\n", "4 Andorra 4.80 AND" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# World GDP Dataset \n", "df = pd.read_csv('2014_World_GDP')\n", "df.head()" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": true }, "outputs": [], "source": [ "data = dict(type = 'choropleth',\n", " locations = df['CODE'],\n", " z = df['GDP (BILLIONS)'],\n", " text = df['COUNTRY'],\n", " colorbar = {'title': 'GDP in Billions US'})" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": true }, "outputs": [], "source": [ "layout = dict(title = '2014 Global GDP',\n", " geo = dict (showframe = False, projection = {'type': 'natural earth'}))" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": true }, "outputs": [], "source": [ "choromap3 = go.Figure(data=[data], layout=layout)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "data": [ { "colorbar": { "title": "GDP in Billions US" }, "locations": [ "AFG", "ALB", "DZA", "ASM", "AND", "AGO", "AIA", "ATG", "ARG", "ARM", "ABW", "AUS", "AUT", "AZE", "BHM", "BHR", "BGD", "BRB", "BLR", "BEL", "BLZ", "BEN", "BMU", "BTN", "BOL", "BIH", "BWA", "BRA", "VGB", "BRN", "BGR", "BFA", "MMR", "BDI", "CPV", "KHM", "CMR", "CAN", "CYM", "CAF", "TCD", "CHL", "CHN", "COL", "COM", "COD", "COG", "COK", "CRI", "CIV", "HRV", "CUB", "CUW", "CYP", "CZE", "DNK", "DJI", "DMA", "DOM", "ECU", "EGY", "SLV", "GNQ", "ERI", "EST", "ETH", "FLK", "FRO", "FJI", "FIN", "FRA", "PYF", "GAB", "GMB", "GEO", "DEU", "GHA", "GIB", "GRC", "GRL", "GRD", "GUM", "GTM", "GGY", "GNB", "GIN", "GUY", "HTI", "HND", "HKG", "HUN", "ISL", "IND", "IDN", "IRN", "IRQ", "IRL", "IMN", "ISR", "ITA", "JAM", "JPN", "JEY", "JOR", "KAZ", "KEN", "KIR", "KOR", "PRK", "KSV", "KWT", "KGZ", "LAO", "LVA", "LBN", "LSO", "LBR", "LBY", "LIE", "LTU", "LUX", "MAC", "MKD", "MDG", "MWI", "MYS", "MDV", "MLI", "MLT", "MHL", "MRT", "MUS", "MEX", "FSM", "MDA", "MCO", "MNG", "MNE", "MAR", "MOZ", "NAM", "NPL", "NLD", "NCL", "NZL", "NIC", "NGA", "NER", "NIU", "MNP", "NOR", "OMN", "PAK", "PLW", "PAN", "PNG", "PRY", "PER", "PHL", "POL", "PRT", "PRI", "QAT", "ROU", "RUS", "RWA", "KNA", "LCA", "MAF", "SPM", "VCT", "WSM", "SMR", "STP", "SAU", "SEN", "SRB", "SYC", "SLE", "SGP", "SXM", "SVK", "SVN", "SLB", "SOM", "ZAF", "SSD", "ESP", "LKA", "SDN", "SUR", "SWZ", "SWE", "CHE", "SYR", "TWN", "TJK", "TZA", "THA", "TLS", "TGO", "TON", "TTO", "TUN", "TUR", "TKM", "TUV", "UGA", "UKR", "ARE", "GBR", "USA", "URY", "UZB", "VUT", "VEN", "VNM", "VGB", "WBG", "YEM", "ZMB", "ZWE" ], "text": [ "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas, The", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burma", "Burundi", "Cabo Verde", "Cambodia", "Cameroon", "Canada", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo, Democratic Republic of the", "Congo, Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Curacao", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Islas Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Polynesia", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guam", "Guatemala", "Guernsey", "Guinea-Bissau", "Guinea", "Guyana", "Haiti", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kosovo", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia, Federated States of", "Moldova", "Monaco", "Mongolia", "Montenegro", "Morocco", "Mozambique", "Namibia", "Nepal", "Netherlands", "New Caledonia", "New Zealand", "Nicaragua", "Nigeria", "Niger", "Niue", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Puerto Rico", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Sudan", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Timor-Leste", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands", "West Bank", "Yemen", "Zambia", "Zimbabwe" ], "type": "choropleth", "z": [ 21.71, 13.4, 227.8, 0.75, 4.8, 131.4, 0.18, 1.24, 536.2, 10.88, 2.52, 1483, 436.1, 77.91, 8.65, 34.05, 186.6, 4.28, 75.25, 527.8, 1.67, 9.24, 5.2, 2.09, 34.08, 19.55, 16.3, 2244, 1.1, 17.43, 55.08, 13.38, 65.29, 3.04, 1.98, 16.9, 32.16, 1794, 2.25, 1.73, 15.84, 264.1, 10360, 400.1, 0.72, 32.67, 14.11, 0.18, 50.46, 33.96, 57.18, 77.15, 5.6, 21.34, 205.6, 347.2, 1.58, 0.51, 64.05, 100.5, 284.9, 25.14, 15.4, 3.87, 26.36, 49.86, 0.16, 2.32, 4.17, 276.3, 2902, 7.15, 20.68, 0.92, 16.13, 3820, 35.48, 1.85, 246.4, 2.16, 0.84, 4.6, 58.3, 2.74, 1.04, 6.77, 3.14, 8.92, 19.37, 292.7, 129.7, 16.2, 2048, 856.1, 402.7, 232.2, 245.8, 4.08, 305, 2129, 13.92, 4770, 5.77, 36.55, 225.6, 62.72, 0.16, 28, 1410, 5.99, 179.3, 7.65, 11.71, 32.82, 47.5, 2.46, 2.07, 49.34, 5.11, 48.72, 63.93, 51.68, 10.92, 11.19, 4.41, 336.9, 2.41, 12.04, 10.57, 0.18, 4.29, 12.72, 1296, 0.34, 7.74, 6.06, 11.73, 4.66, 112.6, 16.59, 13.11, 19.64, 880.4, 11.1, 201, 11.85, 594.3, 8.29, 0.01, 1.23, 511.6, 80.54, 237.5, 0.65, 44.69, 16.1, 31.3, 208.2, 284.6, 552.2, 228.2, 93.52, 212, 199, 2057, 8, 0.81, 1.35, 0.56, 0.22, 0.75, 0.83, 1.86, 0.36, 777.9, 15.88, 42.65, 1.47, 5.41, 307.9, 304.1, 99.75, 49.93, 1.16, 2.37, 341.2, 11.89, 1400, 71.57, 70.03, 5.27, 3.84, 559.1, 679, 64.7, 529.5, 9.16, 36.62, 373.8, 4.51, 4.84, 0.49, 29.63, 49.12, 813.3, 43.5, 0.04, 26.09, 134.9, 416.4, 2848, 17420, 55.6, 63.08, 0.82, 209.2, 187.8, 5.08, 6.64, 45.45, 25.61, 13.74 ] } ], "layout": { "geo": { "projection": { "type": "natural earth" }, "showframe": false }, "title": "2014 Global GDP" } }, "text/html": [ "
" ], "text/vnd.plotly.v1+html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "iplot(choromap3)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "USA had the highest GDP and China followed in the second place in 2014. " ] } ], "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.6.3" } }, "nbformat": 4, "nbformat_minor": 2 }