{"cells":[{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"f80518b2-40fa-ba87-b966-327933809492"},"outputs":[],"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\nimport numpy as np # linear algebra\nimport 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\nfrom subprocess import check_output\nprint(check_output([\"ls\", \"../input\"]).decode(\"utf8\"))\n\n# Any results you write to the current directory are saved as output."},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"b9312faa-e2df-3ec8-7d12-b5f09012a247"},"outputs":[],"source":"page_views_df = pd.read_csv(\"../input/page_views_sample.csv\")\nevents_df = pd.read_csv('../input/events.csv')\ntrain_df = pd.read_csv('../input/clicks_train.csv')"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"c9078203-6ef5-7717-ffb7-53ce8520b909"},"outputs":[],"source":"from datetime import datetime\ndef convert_odd_timestamp(timestamp_ms_relative):\n    TIMESTAMP_DELTA=1465876799998\n    return datetime.fromtimestamp((int(timestamp_ms_relative)+TIMESTAMP_DELTA)//1000)"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"d07d3048-7f48-ad35-fe26-1bbd1a0a3f24"},"outputs":[],"source":"page_views_df['timestamp'] = page_views_df['timestamp'].apply(lambda x: convert_odd_timestamp(x))\nevents_df['timestamp'] = events_df['timestamp'].apply(lambda x: convert_odd_timestamp(x))"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"f8bf68a3-5b5a-9010-67f3-ba4815ca6d1e"},"outputs":[],"source":"pv_events = pd.merge(page_views_df, events_df, on=['uuid','document_id'], how='right')"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"b002ac9e-296e-2ff8-6fce-3d5a3bb4fb7b"},"outputs":[],"source":""}],"metadata":{"_change_revision":0,"_is_fork":false,"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.5.2"}},"nbformat":4,"nbformat_minor":0}