Publish Data Science Articles to the Web using Jupyter, Github and Kyso

Publish Data Science Articles to the Web using Jupyter, Github and Kyso

<strong>Combine these 3 tools to supercharge your DS&nbsp;workflow</strong>

Combine these 3 tools to supercharge your DS workflow

Data science is exploding, more and more organizations are using data to power, well, everything. But it can sometimes still be a little difficult to publish data-science based reports. This might be because the charts are interactive, or because you want a reproducible document, or because it can be difficult to move from the data-science tools to more readable formats.

In this article I’ll go through how using python in Jupyter notebooks, Github and Kyso we can go from getting some raw data to publishing an awesome chart to the web in a few minutes.

Let’s start analyzing some data

I start with assuming you have python3 installed — otherwise go to https://www.python.org/ and download it. Then let’s install Jupyterlab and the plotly extension for awesome interactive charts.

pip3 install jupyterlab
jupyter labextension install @jupyterlab/plotly-extension

Then let’s start Jupyterlab with

jupyter lab

And let’s download some data to play with, I’ve used the recent Eurobarometer data to see how many people in the EU identify with the EU flag, available here.

So now you should have Jupyter open — its a nice interactive place where you can type results and see the live output.

We can then start writing code in the first notebook cell!

import plotly
import pandas as pd
import plotly.graph_objs as go
import country_converter as coco
plotly.offline.init_notebook_mode(connected=True)

This will import all the libraries we need and setup Plotly up to render the chart inside the Jupyter notebook.

cols2skip = [0]
cols = [i for i in range(100) if i not in cols2skip]
df_raw = pd.read_excel('./eb_90_volume_A.xls', sheet_name="QD11.3", skiprows=8, usecols=cols)
df_raw.rename(columns={'UE28\nEU28':'EU28', 'UE28-UK\nEU28-UK':'EU28-UK' }, inplace=True)
df = df_raw.transpose()
df = df.rename(columns=df.iloc[0])
df = df.iloc[1:]
names = df.index.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, let’s 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.choropleth.Marker(
        line = go.choropleth.marker.Line(
            color = 'rgb(0,0,0)',
            width = 0.5
        )),
    colorbar = go.choropleth.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.offline.iplot(fig)

You should now have a nice interactive chart inside your notebook.

Plotly Chart in Jupyterlab

In 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.

Let’s push this notebook to the web

We 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/studyand just drop in the .ipynb file, give it a title and you will have a link to share.

Or else we can use Github for a longer-term project where we might be making a lot of changes. To start head over to Github and make a new project, then do the normal business of

git add .
git commit -m "initial commit"
git push origin master

You will then be able to view your project, and notebook on Github. However, the Plotly plot won’t be visible. So let’s 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, select the main file and you’re done. Your 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. For example, check out this post on Kyso, which is linked to this Github repository.

data-science

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

50 Data Science Jobs That Opened Just Last Week

Data Science and Analytics market evolves to adapt to the constantly changing economic and business environments. Our latest survey report suggests that as the overall Data Science and Analytics market evolves to adapt to the constantly changing economic and business environments, data scientists and AI practitioners should be aware of the skills and tools that the broader community is working on. A good grip in these skills will further help data science enthusiasts to get the best jobs that various industries in their data science functions are offering.

Applications Of Data Science On 3D Imagery Data

The agenda of the talk included an introduction to 3D data, its applications and case studies, 3D data alignment and more.

Data Science Course in Dallas

Become a data analysis expert using the R programming language in this [data science](https://360digitmg.com/usa/data-science-using-python-and-r-programming-in-dallas "data science") certification training in Dallas, TX. You will master data...

32 Data Sets to Uplift your Skills in Data Science | Data Sets

Need a data set to practice with? Data Science Dojo has created an archive of 32 data sets for you to use to practice and improve your skills as a data scientist.

Data Cleaning in R for Data Science

A data scientist/analyst in the making needs to format and clean data before being able to perform any kind of exploratory data analysis.