{"metadata": {"language_info": {"name": "python", "version": "3.6.3", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "mimetype": "text/x-python", "file_extension": ".py", "codemirror_mode": {"name": "ipython", "version": 3}}, "kernelspec": {"name": "python3", "display_name": "Python 3", "language": "python"}}, "cells": [{"cell_type": "code", "metadata": {"_uuid": "7639a780c73460ac77eb17571d6275aebe4a8385", "_cell_guid": "93a524f5-a1fb-42b3-91b6-eb069f356d9a"}, "source": ["# This Python 3 environment comes with many helpful analytics libraries installed\n", "# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n", "# For example, here's several helpful packages to load in \n", "\n", "import numpy as np # linear algebra\n", "import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n", "\n", "# Input data files are available in the \"../input/\" directory.\n", "# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n", "\n", "from subprocess import check_output\n", "print(check_output([\"ls\", \"../input\"]).decode(\"utf8\"))\n", "\n", "# Any results you write to the current directory are saved as output."], "execution_count": null, "outputs": []}, {"cell_type": "markdown", "metadata": {"_uuid": "daceaaa224ce05941878312dce0fa6309ab3bbf7", "_cell_guid": "275cc61c-a9cc-4d9e-9d13-93c35deea0d5"}, "source": ["# Parsing Holiday Data"]}, {"cell_type": "code", "metadata": {"_uuid": "6112d4e2365bacaafa1332d1c8d391dc9e2db945", "_cell_guid": "3cb9de63-b844-4869-b0b5-5529ced5bc85"}, "source": ["events = pd.read_csv(\"../input/holidays_events.csv\")\n", "print(\"# events:\", events.shape[0])\n", "events.sample(10)"], "execution_count": null, "outputs": []}, {"cell_type": "markdown", "metadata": {"_uuid": "53ab7c70cb0ac623d45c68c24447d9f2ffbac8d0", "_cell_guid": "cc33312d-4c6b-4460-9d57-4da6176001ab"}, "source": ["## Work days that make up Bridge days"]}, {"cell_type": "code", "metadata": {"_uuid": "4f7a06f8353551f7ac533dd7d954ef8bde4d3a97", "_cell_guid": "63f31462-ae9c-47ed-a3c1-e55df3bd533b"}, "source": ["events[events.type==\"Work Day\"]"], "execution_count": null, "outputs": []}, {"cell_type": "markdown", "metadata": {"_uuid": "e44bd4e84a283eadefbc160f3e69553fd7225652", "_cell_guid": "abdad936-709b-48a8-b665-32bd28908ab7"}, "source": ["## Transferred Holidays"]}, {"cell_type": "code", "metadata": {"_uuid": "0a0a34589e17eaeb63363c02ae908554f82a77c0", "_cell_guid": "5fb1b76e-0f47-4ea7-8cd6-440c59c9673f"}, "source": ["events[events.type==\"Bridge\"]"], "execution_count": null, "outputs": []}, {"cell_type": "markdown", "metadata": {"_uuid": "9be14105dbe3edb402433f6a16ac64ec0e9a6759", "_cell_guid": "2a1a000b-cf81-4a75-a9fa-2006c0d6edf8"}, "source": ["## Additional Holidays"]}, {"cell_type": "code", "metadata": {"_uuid": "7e528707f0e3a33d132b1fb636c43da6b1ee9ba6", "_cell_guid": "66d7d886-05e3-4eb6-8434-6822dc758e16"}, "source": ["print(\"# additional holidays:\", events[events.type==\"Additional\"].shape[0])\n", "events[events.type==\"Additional\"].tail(10)"], "execution_count": null, "outputs": []}, {"cell_type": "markdown", "metadata": {"_uuid": "a7100afb71baa57461c97c0e7e1ce13d426c1034", "_cell_guid": "e0018729-598c-4c90-83f0-12148407dd9a"}, "source": ["## Events"]}, {"cell_type": "code", "metadata": {"_uuid": "7a4666b2df69d8603fb0697d73b831c0af69dcbb", "_cell_guid": "3c5ec660-2841-447b-adb8-fd261f07b219"}, "source": ["print(\"# events:\", events[events.type==\"Event\"].shape[0])\n", "events[events.type==\"Event\"].tail(10)"], "execution_count": null, "outputs": []}, {"cell_type": "markdown", "metadata": {"_uuid": "e27abd41035590fd19b341c5853f290c911344c3", "_cell_guid": "9c4132ee-48f5-4792-ac05-9c5383d3428d"}, "source": ["## National Holidays"]}, {"cell_type": "code", "metadata": {"_uuid": "9cd8e816fbb2c3429109202b9ecac5dcbdca5170", "_cell_guid": "602a6852-a542-4e6f-9175-5dab90e08e21"}, "source": ["national_holidays = events[\n", "    (events.locale==\"National\") & (\n", "        (events.type==\"Additional\") |  \n", "        (events.type==\"Bridge\") | \n", "        (events.type==\"Holiday\")\n", "    ) & ~events.transferred]\n", "print(\"# National Holiday:\", national_holidays.shape[0])\n", "national_holidays.tail(10)"], "execution_count": null, "outputs": []}, {"cell_type": "code", "metadata": {}, "source": ["national_holidays[national_holidays[\"date\"].duplicated(False)]"], "execution_count": null, "outputs": []}, {"cell_type": "markdown", "metadata": {"_uuid": "f7c3dde4531fb93a5e7436559fa8665107c3d32e", "_cell_guid": "52732b53-4f86-4ab8-8f4a-e954dd8d192b"}, "source": ["## Regional Holidays\n", "\n", "Corresponds to \"state\" in store data."]}, {"cell_type": "code", "metadata": {"_uuid": "c11aea086ff4f8e27fd7b8b0781f585d8c695870", "_cell_guid": "404bece7-33ea-42bf-8f82-27cade0c0d87"}, "source": ["regional_holidays = events[\n", "    (events.locale==\"Regional\") & (\n", "        (events.type==\"Additional\") |  \n", "        (events.type==\"Bridge\") | \n", "        (events.type==\"Holiday\")\n", "    ) & ~events.transferred]\n", "print(\"# Regional Holiday:\", regional_holidays.shape[0])\n", "regional_holidays.tail(10)"], "execution_count": null, "outputs": []}, {"cell_type": "markdown", "metadata": {"_uuid": "5dffdd1a3739029bdc901d3eaea3e8fc99d067c6", "_cell_guid": "319f920b-5c25-4a38-a94a-0a29515a1093"}, "source": [" ## Local Holidays\n", " Corresponds to \"city\" in store data."]}, {"cell_type": "code", "metadata": {"_uuid": "92fde19930a3095e66629ea3779cb373764c5969", "_cell_guid": "2becd559-d125-4988-bfa4-f986a1f31826"}, "source": ["local_holidays = events[\n", "    (events.locale==\"Local\") & (\n", "        (events.type==\"Additional\") |  \n", "        (events.type==\"Bridge\") | \n", "        (events.type==\"Holiday\")\n", "    ) & ~events.transferred]\n", "print(\"# Local Holiday:\", local_holidays.shape[0])\n", "local_holidays.tail(10)"], "execution_count": null, "outputs": []}, {"cell_type": "markdown", "metadata": {"_uuid": "2c7ff5bb92c8fcbc11728d0e6cb37efb0d8c81b3", "_cell_guid": "c7f7ff71-91e4-4065-bb22-e74da1467c73"}, "source": []}], "nbformat_minor": 1, "nbformat": 4}