This is a demo notebook that can be used to explore Contiamo Labs. It uses a demo database created by Contiamo containing transaction information for a mobile app retailer.
In [2]:
import pandas as pd
import contiamo
import seaborn as sns
import numpy as np
In [3]:
transactions = %contiamo query query:sql:48590597:411:g71GXzJjsx4Uvad11ouKjoYbQUNNPy-qRMKkBNZfyx4
customers = %contiamo query query:sql:48590597:441:MG5W2dMjXzYgsHsgdQYzmhv44dxEQX2Lodu5Uh2Hx_s
applications = %contiamo query query:sql:48590597:442:-gz3nbw1fdmtSXkD4zGNA-cVa7s6sQtRn8upCSn6uys
In [4]:
df1 = pd.DataFrame ({
'Age' : customers['Field age'],
'Customer id' : customers['Field customer id']
})
In [5]:
df2 = pd.DataFrame ({
'Revenue' : transactions['Field app price'],
'Application type' : transactions['Field app type'],
'Customer id' : transactions['Field customer id']
})
In [6]:
df = df2.set_index('Customer id').join(df1.set_index('Customer id'))
df['Revenue']=pd.to_numeric(df['Revenue'])
df = df.groupby(['Application type','Age'], as_index=False).sum()
In [7]:
df = df.pivot_table('Revenue', 'Application type', 'Age', fill_value=0)
df
Out[7]:
In [9]:
sns.set_context("poster") # display large charts
sns.heatmap(df, annot=True, fmt=',.0f');