A standard yet flexible skeleton for every kind of Data Science notebook.

Adapted for use with nbdev & Google Colab from xstreamsrl Jupytemplate.

Title

The title of the notebook (above) should be coherent with file name (at the top) and, like the filename, follow the nbdev naming convention. For example, notebook '01' to be added to the project by author 'AB' (initials) and containing code for 'data_exploration' might have the filename 01_AB_data_exploration.ipynb or AB_01_data_exploration.ipynb and title '01_AB_Data_Exploration' or 'AB_01_Data_Exploration'.

Note that this title will also become the title of the notebook in the documentation.

Purpose

State the purpose of the notebook.

Methodology

Quickly describe assumptions and processing steps.

WIP - improvements

Use this section only if the notebook is not final.

Notable TODOs:

todo 1; todo 2; todo 3.

Results

Describe and comment the most important results.

Suggested next steps

State suggested next steps, based on results obtained in this notebook

Setup

Import all the required Python libraries

#test_flag_deps

# general
import os, pickle, pathlib

# Data manipulation
import pandas as pd
import numpy as np

# Options for pandas
pd.options.display.max_columns = 50
pd.options.display.max_rows = 30

# Visualizations
import matplotlib as plt

import plotly
import plotly.graph_objs as go
import plotly.offline as ply
plotly.offline.init_notebook_mode(connected=True)

import altair as alt

import cufflinks as cf
cf.go_offline(connected=True)
cf.set_config_file(theme='white')

Import all required local libraries.

# Include local library paths
import sys
# sys.path.append('path/to/local/lib') # put path to local libraries in system path
# Import local libraries # now local libraries in a non_local directory ('lib') can be easily imported

from nbds_colab.common import *
from nbds_colab.vis import *
from nbds_colab.dataproc import *
from nbds_colab.data import *

Parameter definition

Set all relevant parameters for our notebook. By convention, parameters are uppercase, while all the other variables follow Python's guidelines.

PARAM = 0

Data import

Retrieve required data for analysis.

Data processing

Put here the core of the notebook. Feel free to further split this section into subsections and adjust heading markdown as fits the project.

template2_test[source]

template2_test(test_msg)

Function template2

template2_test('template2')
'template2'

Test local imports

assert common_test('from common') == 'from common'
assert vis_test('from vis') == 'from vis'
assert dataproc_test('from dataproc') == 'from dataproc'
assert data_test('from data') == 'from data'

References

Relevant references:

  1. author1, article1, journal1, year1, url1
  2. author2, article2, journal2, year2, url2