{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Week 8: Unrest via Sparse Credit Card Data" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Using matplotlib backend: TkAgg\n", "Populating the interactive namespace from numpy and matplotlib\n" ] } ], "source": [ "%pylab\n", "%matplotlib inline\n", "import pandas as pd\n", "from pandas import ExcelWriter\n", "from pandas import ExcelFile\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from scipy import stats" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We start the analysis by importing the data. Note, we are only importing the data provided in Table 1 of the Appendix of Dong et al.1 as we are only analysing data from the references days and Day 62.\n", "\n", "**\\*\\* Double Check this with Murray \\*\\***\n", "\n", "TO DO:\n", "\\*\\* Need to test the statistical significance of the data" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "# Contains data about the number of customers during the recorded time period\n", "cust_data = pd.read_excel('edited_Dong_etal_2018_data.xlsx', sheetname='# of Customers')\n", "# Contains data about the customers' median spending amounts during the recorded time period\n", "spend_data = pd.read_excel('edited_Dong_etal_2018_data.xlsx', sheetname='Median spending amount')\n", "# Contains data about the number of transactions during the recorded time period\n", "trans_data = pd.read_excel('edited_Dong_etal_2018_data.xlsx', sheetname='# of transactions')" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", "\n", "
\n", " \n", " \n", " \n", " \n", " | \n", " Distance from event center (km)\n", " \n", " \n", " \n", " | \n", " Min of ref. Days\n", " \n", " \n", " \n", " | \n", " Max of ref. Days\n", " \n", " \n", " \n", " | \n", " Decrease on Day 62\n", " \n", " \n", " |
---|---|---|---|---|
\n", " Distance from event center (km)\n", " \n", " \n", " \n", " | \n", " 1\n", " \n", " \n", " \n", " | \n", " -0.104681\n", " \n", " \n", " \n", " | \n", " -0.101477\n", " \n", " \n", " \n", " | \n", " -0.375261\n", " \n", " \n", " |
\n", " Min of ref. Days\n", " \n", " \n", " \n", " | \n", " -0.104681\n", " \n", " \n", " \n", " | \n", " 1\n", " \n", " \n", " \n", " | \n", " 0.990716\n", " \n", " \n", " \n", " | \n", " 0.855398\n", " \n", " \n", " |
\n", " Max of ref. Days\n", " \n", " \n", " \n", " | \n", " -0.101477\n", " \n", " \n", " \n", " | \n", " 0.990716\n", " \n", " \n", " \n", " | \n", " 1\n", " \n", " \n", " \n", " | \n", " 0.869914\n", " \n", " \n", " |
\n", " Decrease on Day 62\n", " \n", " \n", " \n", " | \n", " -0.375261\n", " \n", " \n", " \n", " | \n", " 0.855398\n", " \n", " \n", " \n", " | \n", " 0.869914\n", " \n", " \n", " \n", " | \n", " 1\n", " \n", " \n", " |