{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","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\nimport os\nprint(os.listdir(\"../input\"))\n\n# Any results you write to the current directory are saved as output.","execution_count":3,"outputs":[{"output_type":"stream","text":"['test', 'sample_submission.csv', 'train.csv']\n","name":"stdout"}]},{"metadata":{},"cell_type":"markdown","source":""},{"metadata":{},"cell_type":"markdown","source":"Training data\nThe total size of the train data is almost 9 GB and we don't want to wait too long just for a first impression, let's load only some rows:"},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"train = pd.read_csv(\"../input/train.csv\", nrows=10000000,\n                    dtype={'acoustic_data': np.int16, 'time_to_failure': np.float64})\ntrain.head(5)","execution_count":4,"outputs":[{"output_type":"execute_result","execution_count":4,"data":{"text/plain":"   acoustic_data  time_to_failure\n0             12           1.4691\n1              6           1.4691\n2              8           1.4691\n3              5           1.4691\n4              8           1.4691","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>acoustic_data</th>\n      <th>time_to_failure</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>12</td>\n      <td>1.4691</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>6</td>\n      <td>1.4691</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>8</td>\n      <td>1.4691</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>5</td>\n      <td>1.4691</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>8</td>\n      <td>1.4691</td>\n    </tr>\n  </tbody>\n</table>\n</div>"},"metadata":{}}]},{"metadata":{},"cell_type":"markdown","source":"We can see two columns: Acoustic data and time_to_failure. The further is the seismic singal and the latter corresponds to the time until the laboratory earthquake takes place. Ok, personally I like to rename the columns as typing \"acoustic\" every time is likely for me to produce errors:"},{"metadata":{"trusted":true},"cell_type":"code","source":"train.rename({\"acoustic_data\": \"signal\", \"time_to_failure\": \"quaketime\"}, axis=\"columns\", inplace=True)\ntrain.head(5)","execution_count":5,"outputs":[{"output_type":"execute_result","execution_count":5,"data":{"text/plain":"   signal  quaketime\n0      12     1.4691\n1       6     1.4691\n2       8     1.4691\n3       5     1.4691\n4       8     1.4691","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>signal</th>\n      <th>quaketime</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>12</td>\n      <td>1.4691</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>6</td>\n      <td>1.4691</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>8</td>\n      <td>1.4691</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>5</td>\n      <td>1.4691</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>8</td>\n      <td>1.4691</td>\n    </tr>\n  </tbody>\n</table>\n</div>"},"metadata":{}}]},{"metadata":{},"cell_type":"markdown","source":"We can see that the quaketime of these first rows seems to be always the same. But is this really true?"},{"metadata":{"trusted":true},"cell_type":"code","source":"for n in range(5):\n    print(train.quaketime.values[n])","execution_count":6,"outputs":[{"output_type":"stream","text":"1.4690999832\n1.4690999821000001\n1.4690999809999998\n1.4690999799000002\n1.4690999787999999\n","name":"stdout"}]},{"metadata":{},"cell_type":"markdown","source":"Aha! We can see that they are not the same and that pandas has rounded them off. And we can see that the time seems to decrease. Let's plot the time to get more familiar with this pattern:"},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.4","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}