Data analysis and presentation with Pandas and D3js

The aim of this notebook is to familiarise myself with jupyter and pandas, as well as to explore their capabilities for knowledge sharing in a multidisciplinary team setting. The expected final output is a d3.js driven chart running in any modern web browser.

Data source

The Monthly Banking Statistics dataset used throughout this example was downloaded from apra.gov.au as an excel spreadsheet file (last accessed on 1 June 2017). It is stored within this project's repo at ./data/MBS_April_2017.xls

About the Monthly Banking Statistics

The Monthly Banking Statistics publication provides selected information on the banking business of individual banks within the domestic market.
It contains high-level breakdowns of the domestic assets and liabilities of each bank as well as more detail on loans & advances to and deposits by different sectors of the economy. Information on securitisation activity is also included. Both Australian-dollar denominated transactions and the Australian-dollar equivalent of foreign-currency denominated transactions are included.

http://www.apra.gov.au/adi/publications/pages/monthly-banking-statistics.aspx

Specs & dependencies

Jupyter

Running on macOS Sierra 10.12.4 with virtualenv installed via pip (9.0.1) and system python (2.7.10)

Server Information:

The version of the notebook server is 5.0.0-b711a93 and is running on:
Python 2.7.10 (default, Feb  6 2017, 23:53:20)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]

Current Kernel Information:

Python 2.7.10 (default, Feb  6 2017, 23:53:20)
Type "copyright", "credits" or "license" for more information.

IPython 5.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

Dependencies

Follow https://pip.pypa.io/en/stable/installing/ to install pip then install virtualenv with pip

[sudo] pip install virtualenv

Once installed, activate it by running from within the virtualenv project directory

source [./d3nb/]bin/activate

then install the required libraries:

  • pytest: python unit test
  • numexpr: to accelerate numerical calculations
  • bottleneck: to accelerate certain types of NaN evaluations
  • numpy: help wrangling some arrays
  • py_d3: run d3js in jupyter
  • xlrd: to read excel (xls) files
pip install pandas pytest numexpr bottleneck numpy py_d3 xlrd

Finally, launch the notebook

jupyter notebook

NB: The recommended way to install pandas is via Anaconda, but it seems excessively huge for this small project, so I opted to cherry-pick from pandas' recommendations instead.

You can also download the complete notebook file.

Notes regarding D3

JavaScript and specifically D3.js runs inline in this notebook via py_d3. Install it as per above then load it using the %load_ext py_d3 ipython built-in magic.

py_d3 uses require.js to load d3.js and appears to become buggy in exported (static) notebooks. This was fixed manually for this exported notebook and should work as intended within an interactive environment.

Sources and inspirations

The process

Please follow along discovering this sample dataset...

In [1]:
import pandas as pd
pd.__version__
Out[1]:
u'0.20.1'
In [2]:
#import pytest as test ## only executing this once at project initiation as it takes ages to run (~5min)
#pd.test()
In [3]:
import numpy as np
np.__version__
Out[3]:
'1.12.1'
In [4]:
import matplotlib
matplotlib.__version__
Out[4]:
'2.0.2'

Import selected sheet from XLS file, skip the first row and parse the column 'Period' as date

Inspect the XLS file in your favourite spreadsheet application to determine the relevant sheet and understand the data structure, then import the file.

In [5]:
xls = pd.read_excel('../data/MBS-BackSeries-March-2017.xls', sheetname='Table 1', header=1, parse_dates=['Period'])
xls.head()
Out[5]:
Period ABN Institution_Name Cash_and_liquid_assets Trading_securities Investment_securities Acceptances_of_customers Gross_loans_and_advances Other_investments Total_resident_assets ... Bonds,_notes_and_long-term_borrowings Other_borrowings Deposits_from_non-financial_corporations Deposits_from_financial_corporations Deposits_from_general_government Deposits_from_households Deposits_from_community_service_organisations_and_non-profit_institutions Other_deposit_accounts Certificates_of_deposit Total_deposits.1
0 2017-03-31 15081596009 AMP Bank Limited 279.700000 0.000000 2094.000000 0.000000 15222.600000 0.000000 17761.400000 ... 2270.000000 121.100000 1340.90000 600.100000 715.500000 3572.300000 149.400000 0.0 1223.00000 7601.200000
1 2017-03-31 48848300367 Agricultural Bank of China Limited 267.300000 0.000000 1696.300000 0.000000 979.900000 0.000000 2961.900000 ... 0.000000 883.200000 14.80000 691.400000 0.000000 0.000000 0.000000 0.0 69.90000 776.100000
2 2017-03-31 37002950745 Arab Bank Australia Limited 55.600000 0.000000 275.060000 0.000000 655.020000 0.070000 991.740000 ... 0.000000 0.000000 327.75000 147.740000 9.500000 320.100000 11.270000 0.0 6.00000 822.360000
3 2017-03-31 11005357522 Australia and New Zealand Banking Group Limited 20442.952218 21415.157549 36701.779631 62.153882 375785.098833 15657.934814 578829.821618 ... 10100.349195 28713.270153 89445.36163 48920.814778 3590.465969 114576.240632 3358.312558 0.0 52104.71879 311995.914357
4 2017-03-31 48087649741 Australian Military Bank Ltd 57.400000 0.000000 117.700000 0.000000 983.200000 8.600000 1177.900000 ... 0.000000 2.000000 215.60000 34.500000 0.000000 518.100000 304.900000 0.0 0.00000 1073.100000

5 rows × 38 columns

Select columns of interest and save it in a new DataFrame

In [6]:
assets = xls[['Period','Institution_Name', 'Cash_and_liquid_assets']]
assets.head()
Out[6]:
Period Institution_Name Cash_and_liquid_assets
0 2017-03-31 AMP Bank Limited 279.700000
1 2017-03-31 Agricultural Bank of China Limited 267.300000
2 2017-03-31 Arab Bank Australia Limited 55.600000
3 2017-03-31 Australia and New Zealand Banking Group Limited 20442.952218
4 2017-03-31 Australian Military Bank Ltd 57.400000

Pivot the DataFrame assets and set the index to the Period column

In [7]:
assets_pivot = assets.pivot(index='Period', columns='Institution_Name', values='Cash_and_liquid_assets')
assets_pivot.head()
Out[7]:
Institution_Name ABN AMRO Bank N.V. AMP Bank Limited Adelaide Bank Limited Agricultural Bank of China Limited Allied Irish Banks, Public Limited Company Arab Bank Australia Limited Australia and New Zealand Banking Group Limited Australian Military Bank Ltd Auswide Bank Ltd BNP Paribas ... The Toronto-Dominion Bank UBS AG Union Bank of India United Overseas Bank Limited Unity Bank Limited Victoria Teachers Limited WestLB AG Westdeutsche Landesbank Girozentrale Westpac Banking Corporation Woori Bank
Period
2002-06-30 486.40 221.9 50.3 NaN NaN 17.9 1685.900000 NaN NaN 4720.85 ... 1041.40 NaN NaN 34.2 NaN NaN NaN 34.0 11917.916905 NaN
2002-09-30 822.50 239.9 56.4 NaN NaN 39.8 2011.600000 NaN NaN 2472.70 ... 525.30 NaN NaN 17.4 NaN NaN NaN 32.7 6820.369213 NaN
2002-12-31 815.93 441.2 86.4 NaN NaN 21.5 2438.100000 NaN NaN 648.40 ... 526.62 NaN NaN 7.1 NaN NaN 44.3 NaN 6994.435948 NaN
2003-03-31 1074.00 299.1 48.5 NaN NaN 56.0 1709.500000 NaN NaN 407.70 ... 944.20 NaN NaN 19.8 NaN NaN 31.8 NaN 8155.300000 NaN
2003-06-30 936.00 299.4 144.4 NaN NaN 12.6 1783.582769 NaN NaN 579.60 ... 878.30 NaN NaN 8.7 NaN NaN 39.3 NaN 8993.600000 NaN

5 rows × 145 columns

Clean up: drop columns with any NaN values

This is very heavy-handed, but does the job for the purposes of a demo

In [8]:
assets_pivot = assets_pivot.dropna(axis=1)
assets_pivot.head(20)
Out[8]:
Institution_Name AMP Bank Limited Arab Bank Australia Limited Australia and New Zealand Banking Group Limited BNP Paribas Bank of America, National Association Bank of Queensland Limited Commonwealth Bank of Australia HSBC Bank Australia Limited ING Bank (Australia) Limited Macquarie Bank Limited National Australia Bank Limited Royal Bank of Canada Standard Chartered Bank State Street Bank and Trust Company Suncorp-Metway Limited Taiwan Business Bank United Overseas Bank Limited Westpac Banking Corporation
Period
2002-06-30 221.9 17.90 1685.900000 4720.85 66.1 91.6 7766.3 69.500000 81.8 2250.5 6620.8 311.307082 39.2 188.8 1230.1 5.7 34.2 11917.916905
2002-09-30 239.9 39.80 2011.600000 2472.70 44.8 107.4 4638.8 83.500000 85.7 2352.3 5633.6 259.423392 32.3 79.9 621.9 4.6 17.4 6820.369213
2002-12-31 441.2 21.50 2438.100000 648.40 71.3 127.5 4204.0 219.100000 140.6 2325.1 4808.6 796.600000 37.0 123.7 1061.9 8.1 7.1 6994.435948
2003-03-31 299.1 56.00 1709.500000 407.70 31.0 118.9 4739.2 163.100000 17.5 2633.7 4820.8 544.200000 38.9 151.2 386.0 6.4 19.8 8155.300000
2003-06-30 299.4 12.60 1783.582769 579.60 101.5 67.9 5067.1 259.100000 105.0 2117.5 4824.6 532.100000 36.4 158.8 903.4 7.0 8.7 8993.600000
2003-09-30 69.7 5.60 1966.562208 1096.40 133.0 297.5 5397.6 137.100000 1.5 3904.0 4252.4 323.300000 36.4 421.5 1061.5 10.2 13.8 9264.900000
2003-12-31 128.8 48.20 2785.310797 493.30 159.1 308.3 5296.7 371.000000 4.7 3919.5 6393.0 576.700000 41.2 504.1 971.1 7.8 4.0 11479.500000
2004-03-31 202.5 9.40 2835.030846 457.50 140.8 132.0 6516.1 157.600000 46.6 5927.3 3947.9 446.800000 46.5 282.6 683.1 13.3 7.2 5854.100000
2004-04-30 103.6 3.40 2945.095354 716.90 130.3 105.6 6266.3 316.700000 37.5 6037.3 5058.4 420.800000 41.6 233.9 558.2 7.8 71.3 5980.500000
2004-05-31 85.1 21.40 3296.443490 774.90 107.0 267.7 6601.6 533.900000 415.7 6536.8 3735.1 329.900000 41.0 336.7 551.2 10.5 12.0 4765.900000
2004-06-30 45.0 17.80 3414.255170 1745.70 208.5 61.8 8184.2 855.900000 0.2 5153.1 4490.5 620.600000 41.2 307.3 839.2 8.9 7.6 5229.400000
2004-07-31 99.5 19.20 3861.989671 1418.20 181.9 40.2 8547.0 651.700000 17.3 5015.5 4761.2 424.800000 40.8 331.1 691.4 8.8 14.5 4237.500000
2004-08-31 64.2 21.46 3570.326976 1604.70 104.5 157.8 6978.5 262.000000 11.8 5225.5 3829.7 347.500000 39.1 753.2 535.8 9.2 29.6 3974.100000
2004-09-30 97.2 6.40 2459.185428 1318.40 135.9 129.2 5989.8 158.691543 38.0 4030.9 5421.9 347.900000 39.2 562.8 486.6 14.1 2.4 5432.400000
2004-10-31 90.2 16.90 2389.827762 1202.80 143.0 129.3 4600.6 359.544385 32.0 3883.3 4034.5 852.080048 39.0 439.9 748.5 9.1 12.1 5684.400000
2004-11-30 86.3 14.50 3928.459504 1564.20 122.8 118.6 6513.5 278.505147 3.8 5059.1 5185.6 538.849550 38.8 576.4 569.3 9.1 3.7 5766.100000
2004-12-31 105.7 16.10 2798.189362 1540.00 125.0 114.5 4807.5 287.939484 369.0 4710.3 3943.3 413.341135 39.9 330.1 573.4 9.8 11.2 6047.700000
2005-01-31 125.9 21.70 3392.428620 2018.40 144.4 79.1 4688.8 311.270499 275.3 4511.9 179.3 432.510930 39.5 380.5 329.2 11.8 3.6 6655.000000
2005-02-28 9.1 21.80 2799.138209 753.20 1288.7 477.7 7777.6 296.079416 159.2 5084.4 3122.6 548.389016 39.3 479.0 311.3 10.0 30.3 4642.300000
2005-03-31 50.4 31.80 3604.724525 276.50 101.3 95.1 4683.2 133.900000 4.6 5804.7 2631.1 594.070734 39.1 289.6 988.3 11.1 2.8 4866.300000

Remove the first 17 rows where data is quarterly instead of monthly, resetting our dataset start date to the first year with monthly data.

In [9]:
ap2 = assets_pivot.iloc[17:]
ap2.head()
Out[9]:
Institution_Name AMP Bank Limited Arab Bank Australia Limited Australia and New Zealand Banking Group Limited BNP Paribas Bank of America, National Association Bank of Queensland Limited Commonwealth Bank of Australia HSBC Bank Australia Limited ING Bank (Australia) Limited Macquarie Bank Limited National Australia Bank Limited Royal Bank of Canada Standard Chartered Bank State Street Bank and Trust Company Suncorp-Metway Limited Taiwan Business Bank United Overseas Bank Limited Westpac Banking Corporation
Period
2005-01-31 125.9 21.7 3392.428620 2018.4 144.4 79.1 4688.8 311.270499 275.30 4511.9 179.3 432.510930 39.5 380.5 329.2 11.8 3.6 6655.0
2005-02-28 9.1 21.8 2799.138209 753.2 1288.7 477.7 7777.6 296.079416 159.20 5084.4 3122.6 548.389016 39.3 479.0 311.3 10.0 30.3 4642.3
2005-03-31 50.4 31.8 3604.724525 276.5 101.3 95.1 4683.2 133.900000 4.60 5804.7 2631.1 594.070734 39.1 289.6 988.3 11.1 2.8 4866.3
2005-04-30 87.6 26.5 4248.751390 1024.1 101.3 198.2 4157.7 215.550745 20.30 6800.7 2991.9 726.023514 38.9 323.2 435.5 10.2 1.8 5552.2
2005-05-31 58.6 20.5 5909.597290 1331.4 12.5 91.9 4305.1 99.482049 17.14 6910.9 3218.7 523.003922 39.0 488.9 234.0 13.3 2.2 6367.8

Let's see what we've got

Now that we have a reasonably clean dataset, it's time to take a glance at it.

In [10]:
%matplotlib inline
ap2.plot(figsize=[16,6])
Out[10]:
<matplotlib.axes._subplots.AxesSubplot at 0x110e8a8d0>

Find Institution_Name with highest cash reserve

This can be eyeballed in the above chart. Explicitly filtering this entity as our institution of focus allows us to create a separate DataFrame

In [11]:
highest_name = (ap2.max() - ap2.min()).idxmax()
highest_name
Out[11]:
u'Commonwealth Bank of Australia'

Create new DataFrame for highest_name

In [12]:
highest_df = ap2.filter(['Period', highest_name])
highest_df.head()
Out[12]:
Institution_Name Commonwealth Bank of Australia
Period
2005-01-31 4688.8
2005-02-28 7777.6
2005-03-31 4683.2
2005-04-30 4157.7
2005-05-31 4305.1

Create new DataFrame excluding highest_name

In [13]:
rest = ap2.drop(highest_name, axis=1)
rest.head()
Out[13]:
Institution_Name AMP Bank Limited Arab Bank Australia Limited Australia and New Zealand Banking Group Limited BNP Paribas Bank of America, National Association Bank of Queensland Limited HSBC Bank Australia Limited ING Bank (Australia) Limited Macquarie Bank Limited National Australia Bank Limited Royal Bank of Canada Standard Chartered Bank State Street Bank and Trust Company Suncorp-Metway Limited Taiwan Business Bank United Overseas Bank Limited Westpac Banking Corporation
Period
2005-01-31 125.9 21.7 3392.428620 2018.4 144.4 79.1 311.270499 275.30 4511.9 179.3 432.510930 39.5 380.5 329.2 11.8 3.6 6655.0
2005-02-28 9.1 21.8 2799.138209 753.2 1288.7 477.7 296.079416 159.20 5084.4 3122.6 548.389016 39.3 479.0 311.3 10.0 30.3 4642.3
2005-03-31 50.4 31.8 3604.724525 276.5 101.3 95.1 133.900000 4.60 5804.7 2631.1 594.070734 39.1 289.6 988.3 11.1 2.8 4866.3
2005-04-30 87.6 26.5 4248.751390 1024.1 101.3 198.2 215.550745 20.30 6800.7 2991.9 726.023514 38.9 323.2 435.5 10.2 1.8 5552.2
2005-05-31 58.6 20.5 5909.597290 1331.4 12.5 91.9 99.482049 17.14 6910.9 3218.7 523.003922 39.0 488.9 234.0 13.3 2.2 6367.8

Get the mean of all remaining entities

In [14]:
rest['avg'] = rest.mean(axis=1)
rest.head()
Out[14]:
Institution_Name AMP Bank Limited Arab Bank Australia Limited Australia and New Zealand Banking Group Limited BNP Paribas Bank of America, National Association Bank of Queensland Limited HSBC Bank Australia Limited ING Bank (Australia) Limited Macquarie Bank Limited National Australia Bank Limited Royal Bank of Canada Standard Chartered Bank State Street Bank and Trust Company Suncorp-Metway Limited Taiwan Business Bank United Overseas Bank Limited Westpac Banking Corporation avg
Period
2005-01-31 125.9 21.7 3392.428620 2018.4 144.4 79.1 311.270499 275.30 4511.9 179.3 432.510930 39.5 380.5 329.2 11.8 3.6 6655.0 1112.459415
2005-02-28 9.1 21.8 2799.138209 753.2 1288.7 477.7 296.079416 159.20 5084.4 3122.6 548.389016 39.3 479.0 311.3 10.0 30.3 4642.3 1180.735685
2005-03-31 50.4 31.8 3604.724525 276.5 101.3 95.1 133.900000 4.60 5804.7 2631.1 594.070734 39.1 289.6 988.3 11.1 2.8 4866.3 1148.552662
2005-04-30 87.6 26.5 4248.751390 1024.1 101.3 198.2 215.550745 20.30 6800.7 2991.9 726.023514 38.9 323.2 435.5 10.2 1.8 5552.2 1341.336803
2005-05-31 58.6 20.5 5909.597290 1331.4 12.5 91.9 99.482049 17.14 6910.9 3218.7 523.003922 39.0 488.9 234.0 13.3 2.2 6367.8 1490.524898

Merge mean and highest into a single DataFrame

In [15]:
highest_df['mrkt_mean'] = rest['avg']
highest_df.head()
Out[15]:
Institution_Name Commonwealth Bank of Australia mrkt_mean
Period
2005-01-31 4688.8 1112.459415
2005-02-28 7777.6 1180.735685
2005-03-31 4683.2 1148.552662
2005-04-30 4157.7 1341.336803
2005-05-31 4305.1 1490.524898
In [16]:
highest_df.plot(figsize=[10,6])
Out[16]:
<matplotlib.axes._subplots.AxesSubplot at 0x11133e590>

The institution of focus - CBA, being one of the "big four" - is rather off from the market average. We need to dig further...

Get max value of all market players excluding our selected entity stored in highest_df

In [17]:
rest['max'] = rest.max(axis=1)
rest.head()
Out[17]:
Institution_Name AMP Bank Limited Arab Bank Australia Limited Australia and New Zealand Banking Group Limited BNP Paribas Bank of America, National Association Bank of Queensland Limited HSBC Bank Australia Limited ING Bank (Australia) Limited Macquarie Bank Limited National Australia Bank Limited Royal Bank of Canada Standard Chartered Bank State Street Bank and Trust Company Suncorp-Metway Limited Taiwan Business Bank United Overseas Bank Limited Westpac Banking Corporation avg max
Period
2005-01-31 125.9 21.7 3392.428620 2018.4 144.4 79.1 311.270499 275.30 4511.9 179.3 432.510930 39.5 380.5 329.2 11.8 3.6 6655.0 1112.459415 6655.0
2005-02-28 9.1 21.8 2799.138209 753.2 1288.7 477.7 296.079416 159.20 5084.4 3122.6 548.389016 39.3 479.0 311.3 10.0 30.3 4642.3 1180.735685 5084.4
2005-03-31 50.4 31.8 3604.724525 276.5 101.3 95.1 133.900000 4.60 5804.7 2631.1 594.070734 39.1 289.6 988.3 11.1 2.8 4866.3 1148.552662 5804.7
2005-04-30 87.6 26.5 4248.751390 1024.1 101.3 198.2 215.550745 20.30 6800.7 2991.9 726.023514 38.9 323.2 435.5 10.2 1.8 5552.2 1341.336803 6800.7
2005-05-31 58.6 20.5 5909.597290 1331.4 12.5 91.9 99.482049 17.14 6910.9 3218.7 523.003922 39.0 488.9 234.0 13.3 2.2 6367.8 1490.524898 6910.9

Get entity belonging to max value of all market players excluding our selected entity

In [18]:
rest['max_entity'] = rest.idxmax(axis=1)
rest.head()
Out[18]:
Institution_Name AMP Bank Limited Arab Bank Australia Limited Australia and New Zealand Banking Group Limited BNP Paribas Bank of America, National Association Bank of Queensland Limited HSBC Bank Australia Limited ING Bank (Australia) Limited Macquarie Bank Limited National Australia Bank Limited Royal Bank of Canada Standard Chartered Bank State Street Bank and Trust Company Suncorp-Metway Limited Taiwan Business Bank United Overseas Bank Limited Westpac Banking Corporation avg max max_entity
Period
2005-01-31 125.9 21.7 3392.428620 2018.4 144.4 79.1 311.270499 275.30 4511.9 179.3 432.510930 39.5 380.5 329.2 11.8 3.6 6655.0 1112.459415 6655.0 Westpac Banking Corporation
2005-02-28 9.1 21.8 2799.138209 753.2 1288.7 477.7 296.079416 159.20 5084.4 3122.6 548.389016 39.3 479.0 311.3 10.0 30.3 4642.3 1180.735685 5084.4 Macquarie Bank Limited
2005-03-31 50.4 31.8 3604.724525 276.5 101.3 95.1 133.900000 4.60 5804.7 2631.1 594.070734 39.1 289.6 988.3 11.1 2.8 4866.3 1148.552662 5804.7 Macquarie Bank Limited
2005-04-30 87.6 26.5 4248.751390 1024.1 101.3 198.2 215.550745 20.30 6800.7 2991.9 726.023514 38.9 323.2 435.5 10.2 1.8 5552.2 1341.336803 6800.7 Macquarie Bank Limited
2005-05-31 58.6 20.5 5909.597290 1331.4 12.5 91.9 99.482049 17.14 6910.9 3218.7 523.003922 39.0 488.9 234.0 13.3 2.2 6367.8 1490.524898 6910.9 Macquarie Bank Limited

Merge data, plot and save as CSV file

In [19]:
highest_df['mrkt_max'] = rest['max']
highest_df['mrkt_max_entity'] = rest['max_entity']
highest_df.head()
Out[19]:
Institution_Name Commonwealth Bank of Australia mrkt_mean mrkt_max mrkt_max_entity
Period
2005-01-31 4688.8 1112.459415 6655.0 Westpac Banking Corporation
2005-02-28 7777.6 1180.735685 5084.4 Macquarie Bank Limited
2005-03-31 4683.2 1148.552662 5804.7 Macquarie Bank Limited
2005-04-30 4157.7 1341.336803 6800.7 Macquarie Bank Limited
2005-05-31 4305.1 1490.524898 6910.9 Macquarie Bank Limited
In [20]:
highest_df.plot(figsize=[10,6])
Out[20]:
<matplotlib.axes._subplots.AxesSubplot at 0x1110dd9d0>
In [21]:
highest_df.to_csv('../data/cba_vs_mrkt_liquid_cash_assets.csv', sep=',', na_rep='N/A')

Load py_d3 and build chart

NB: chart script was written outside of the notebook. See the source at /interactive/bank-report/html/js/difference.js?v=1.2.0

In [22]:
%load_ext py_d3
In [23]:
%%d3

<style>
    .wrap{border:1px solid rgba(0,0,0,.35);margin:1em auto;display:block;position:relative;width:98%;max-width:620px;height:auto;border:4px solid #fff;box-shadow:0 0 3px 2px rgba(100,100,100,.35);font:10px sans-serif}div#chart{margin:0;position:relative}.wrap h1{margin:0!important;padding:.5em 0;text-align:center;font-family:serif;background-color:#fc0;color:black;letter-spacing:1px}.axis path,.axis line{fill:none;stroke:#000;shape-rendering:crispEdges}.area.above{fill:rgba(145,207,96,.65)}.area.below{fill:rgba(252,141,89,.65)}.line{fill:none;stroke:#000;stroke-width:1px}#mrkt_mean{fill:none;stroke:#fc0;stroke:#ccc;stroke-width:1px}circle.tooltip{fill:rgba(0,0,0,.2);stroke:grey}circle.tooltip:hover{fill:rgba(0,0,0,.1);stroke:black}g.legend line{stroke:black;stroke-width:2}g.legend text{stroke:black;fill:none;font-size:12px}#tooltip{position:absolute;right:15%;top:10px;opacity:1;width:33%;color:black;padding:0;font-family:monospace;font-size:1.2em}hr{border-top:1px dashed #8c8b8b}abbr{font-weight:bold;cursor:help;text-decoration: none;border-bottom: 1px dotted black;}
</style>

<div class="wrap">
    <h1>
        Cash and liquid asset reserves (MoM)
        <br> <abbr title="Commonwealth Bank of Australia">CBA</abbr> <i>vs</i> top reserve <i>vs</i> market mean
        <br></h1>
    <div id="chart"></div>
</div>

<script src="../html/js/difference.js?v=1.2.0"></script>

Cash and liquid asset reserves (MoM)
CBA vs top reserve vs market mean