Publish data-science articles to the web using Jupyter, Github and Kyso

EU28-UK':'EU28-UK' }, inplace=True)df = df_raw.

transpose()df = df.


iloc[0])df = df.

iloc[1:]names = df.


tolist()names = ['GR' if (x == 'EL') else x for x in names]names = ['GB' if (x == 'UK') else x for x in names]iso3 = coco.

convert(names=names, to='ISO3', not_found=None)Then we can wrangle with the data and set it up for plotting, there’s not much to explain here, I came up with this code after a few minutes of playing around and examining the data-shape.

Finally, lets plot the data:data = [go.

Choropleth( locations = iso3, z = df['Tend to agree'] * 100, text = iso3, locationmode="ISO-3", reversescale=True, colorscale="Blues", marker = go.


Marker( line = go.



Line( color = 'rgb(0,0,0)', width = 0.

5 )), colorbar = go.


ColorBar( ticksuffix = '%', title = '% identify', len=0.

5, ),)]layout = { "height": 700, "width": 700, "margin" : {"t": 0, "b": 0, "l": 0, "r": 0}, "geo": { "lataxis": {"range": [36.

0, 65.

0]}, "lonaxis": {"range": [-12.

0, 36.

0]}, "projection": {"type": "transverse mercator"}, "resolution": 50, "showcoastlines": True, "showframe": True, "showcountries": True, }}fig = go.

Figure(data = data, layout = layout)plotly.


iplot(fig)You should now have a nice interactive chart inside your notebook.

You should have an interactive chart inside your notebookIn Jupyter you can also write a bunch of annotations to your analysis by changing the cell to a markdown type, and then writing whatever you like.

Lets push this notebook to the webWe have a few choices now to get this notebook on the web where we can share it.

I’ve already pushed this to the web at http://kyso.

io/eoin/do-i-identify-with-eu-flag where you can see a preview.

Our first choice is that we can just upload it to Kyso.

Go to https://kyso.

io/create/study and just drop in the .

ipynb file, give it a title and you will have a link to shareOr else we can use Github for longer term project where might be making a lot of changes.

To start head over to Github and make a new project, then do the normal business ofgit add .

git commit -m "initial commit"git push origin masterYou will then be able to view your project, and notebook on Github.

However the Plotly plot wont be visible.

So lets import this project to Kyso.

Head to https://kyso.

io/github and sign in with Github, search for your project, hit “Connect to Kyso” for that project and your done.

You notebook will be visible on Kyso and any time you commit to that repository it will get reflected on Kyso meaning you can continuously update your analysis.


. More details

Leave a Reply