<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Heatmap of revenue depending on application type and customer age
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.
Step1:  Query data into Contiamo
Step2:  Select data from the customers table
Step3:  Select data from the transactions table
Step4:  Merge tables and group by application type and age
Step5:  Convert table into matrix
Step6:  Display heatmap
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
import contiamo
import seaborn as sns
import numpy as np
Explanation: Heatmap of revenue depending on application type and customer age
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.
End of explanation
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            
Explanation: Query data into Contiamo
End of explanation
df1 = pd.DataFrame ({
        'Age' : customers['Field age'],
        'Customer id' : customers['Field customer id']
    })
Explanation: Select data from the customers table
End of explanation
df2 = pd.DataFrame ({
        'Revenue' : transactions['Field app price'],
        'Application type' : transactions['Field app type'],
        'Customer id' : transactions['Field customer id']
        })
Explanation: Select data from the transactions table
End of explanation
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()
Explanation: Merge tables and group by application type and age
End of explanation
df = df.pivot_table('Revenue', 'Application type', 'Age', fill_value=0)
df
Explanation: Convert table into matrix
End of explanation
sns.set_context("poster")  # display large charts
sns.heatmap(df, annot=True, fmt=',.0f');
Explanation: Display heatmap
End of explanation
<END_TASK>