execChoropleth_World_GDP
In [ ]:
!pip install nbconvert
In [ ]:
!pip install chart_studio
In [ ]:
def configure_plotly_browser_state():
  import IPython
  display(IPython.core.display.HTML('''
        <script src="/static/components/requirejs/require.js"></script>
        <script>
          requirejs.config({
            paths: {
              base: '/static/base',
              plotly: 'https://cdn.plot.ly/plotly-1.5.1.min.js?noext',
            },
          });
        </script>
        '''))
In [ ]:
import chart_studio.plotly as py
import pandas as pd
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, iplot, plot
%matplotlib inline
init_notebook_mode(connected = True)
In [ ]:
df = pd.read_csv('/content/2014_World_GDP')
df.head(1)
Out[ ]:
COUNTRY GDP (BILLIONS) CODE
0 Afghanistan 21.71 AFG
In [ ]:
data = dict(type='choropleth',
            locations = df['CODE'],
            text = df['COUNTRY'],
            z = df['GDP (BILLIONS)'],
            colorscale = 'YlOrRd')
In [ ]:
layout = dict(title = 'World GDP', 
              geo = dict(showframe = False, projection = {'type':'mercator'}))
In [ ]:
choromap = go.Figure(data = [data], layout = layout)
In [ ]:
configure_plotly_browser_state()
iplot(choromap)
In [ ]:
# ** LAST CELL ** #
CHLOROPLETH MAPS
WORLD GDP AS EXAMPLE