East Africa Mobile-cellular telephone subscriptions

In [46]:
import numpy as np
import pandas as pd
from plotly import __version__
import cufflinks as cf

# import js libraries
from plotly.offline import download_plotlyjs,init_notebook_mode,plot,iplot

%matplotlib inline
In [47]:
# connect js to notebook
init_notebook_mode(connected=True)
In [48]:
cf.go_offline()
IOPub data rate exceeded.
The notebook server will temporarily stop sending output
to the client in order to avoid crashing it.
To change this limit, set the config variable
`--NotebookApp.iopub_data_rate_limit`.
In [19]:
def prep_data():
    """
    Read, Transpose, index and name columns
    """
    df = pd.read_csv('/Users/4bic/projects/deliberate_practice/e-a_data/E-A_cellular_subscriptions.csv').T
    df.rename(index=str, columns={0:'Kenya',1:'Sudan',
                                  2:'Tanzania',3:'Uganda',
                                  4:'Rwanda'},inplace=True)

    df.drop(df.index[0],inplace=True)
    
    return df
    
data = prep_data()  

Line Plot

In [20]:
data.iplot()

Scatter Plot

In [21]:
data.iplot(kind='scatter',mode='markers',size=20)

Bar Plot

In [22]:
data.iplot(kind='bar')

Box Plot

In [23]:
data.iplot(kind='box')

3D Surface plot

In [24]:
data.iplot(kind='surface',colorscale='rdylbu')

Histogram

In [25]:
data.iplot(kind='hist',bins=30)

Overlapping Histograms

Turn column on / off by clicking on the legend

In [26]:
data.iplot(kind='hist',bins=30)

Spread type

In [27]:
data.iplot(kind='spread')

East Africa Cellular subscriptions per 100 inhabitants

In [28]:
df_ph = pd.read_csv('/Users/4bic/projects/deliberate_practice/e-a_data/E-A_cellulars_per_100.csv',index_col='Year')
df_ph.head()
Out[28]:
Kenya Sudan Tanzania Uganda Rwanda
Year
2000 0.41 0.07 0.32 0.52 0.46
2001 1.87 0.30 0.79 1.13 0.74
2002 3.60 0.53 1.69 1.52 0.92
2003 4.69 1.44 3.53 2.89 1.43
2004 7.31 2.80 5.14 4.20 1.48

Line Plot

In [29]:
df_ph.iplot()

Spread

In [30]:
df_ph.iplot(kind='spread')