{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom IPython.display import Video","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-08-02T04:42:35.958968Z","iopub.execute_input":"2022-08-02T04:42:35.959454Z","iopub.status.idle":"2022-08-02T04:42:36.595203Z","shell.execute_reply.started":"2022-08-02T04:42:35.959355Z","shell.execute_reply":"2022-08-02T04:42:36.594015Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv('../input/dfl-bundesliga-data-shootout/train.csv') ","metadata":{"execution":{"iopub.status.busy":"2022-08-02T04:47:30.949055Z","iopub.execute_input":"2022-08-02T04:47:30.949413Z","iopub.status.idle":"2022-08-02T04:47:30.967729Z","shell.execute_reply.started":"2022-08-02T04:47:30.949385Z","shell.execute_reply":"2022-08-02T04:47:30.966903Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T04:47:33.060618Z","iopub.execute_input":"2022-08-02T04:47:33.061647Z","iopub.status.idle":"2022-08-02T04:47:33.072762Z","shell.execute_reply.started":"2022-08-02T04:47:33.061610Z","shell.execute_reply":"2022-08-02T04:47:33.071857Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T04:47:35.626889Z","iopub.execute_input":"2022-08-02T04:47:35.627303Z","iopub.status.idle":"2022-08-02T04:47:35.641597Z","shell.execute_reply.started":"2022-08-02T04:47:35.627265Z","shell.execute_reply":"2022-08-02T04:47:35.640272Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T04:47:39.315854Z","iopub.execute_input":"2022-08-02T04:47:39.316246Z","iopub.status.idle":"2022-08-02T04:47:39.327266Z","shell.execute_reply.started":"2022-08-02T04:47:39.316204Z","shell.execute_reply":"2022-08-02T04:47:39.326156Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.heatmap(df.isnull(),yticklabels=False,cbar=False)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T04:48:48.429571Z","iopub.execute_input":"2022-08-02T04:48:48.430319Z","iopub.status.idle":"2022-08-02T04:48:48.649945Z","shell.execute_reply.started":"2022-08-02T04:48:48.430283Z","shell.execute_reply":"2022-08-02T04:48:48.648859Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# we will handle missing values by replacing them with the 'Mode' value because of these are all Categorical features\ndf['event_attributes']=df['event_attributes'].fillna(df['event_attributes'].mode()[0])","metadata":{"execution":{"iopub.status.busy":"2022-08-02T04:49:45.857191Z","iopub.execute_input":"2022-08-02T04:49:45.857649Z","iopub.status.idle":"2022-08-02T04:49:45.866404Z","shell.execute_reply.started":"2022-08-02T04:49:45.857595Z","shell.execute_reply":"2022-08-02T04:49:45.865219Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.heatmap(df.isnull(),yticklabels=False,cbar=False)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T04:49:52.962846Z","iopub.execute_input":"2022-08-02T04:49:52.963290Z","iopub.status.idle":"2022-08-02T04:49:53.148096Z","shell.execute_reply.started":"2022-08-02T04:49:52.963245Z","shell.execute_reply":"2022-08-02T04:49:53.147043Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T04:50:01.237050Z","iopub.execute_input":"2022-08-02T04:50:01.237464Z","iopub.status.idle":"2022-08-02T04:50:01.249109Z","shell.execute_reply.started":"2022-08-02T04:50:01.237429Z","shell.execute_reply":"2022-08-02T04:50:01.248128Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.describe()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T04:47:41.853790Z","iopub.execute_input":"2022-08-02T04:47:41.854554Z","iopub.status.idle":"2022-08-02T04:47:41.868853Z","shell.execute_reply.started":"2022-08-02T04:47:41.854515Z","shell.execute_reply":"2022-08-02T04:47:41.867681Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['event_attributes'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T04:47:44.820317Z","iopub.execute_input":"2022-08-02T04:47:44.820935Z","iopub.status.idle":"2022-08-02T04:47:44.830739Z","shell.execute_reply.started":"2022-08-02T04:47:44.820901Z","shell.execute_reply":"2022-08-02T04:47:44.829845Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.event","metadata":{"execution":{"iopub.status.busy":"2022-08-02T04:51:56.673783Z","iopub.execute_input":"2022-08-02T04:51:56.674159Z","iopub.status.idle":"2022-08-02T04:51:56.682578Z","shell.execute_reply.started":"2022-08-02T04:51:56.674127Z","shell.execute_reply":"2022-08-02T04:51:56.681562Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.event.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T04:52:22.266720Z","iopub.execute_input":"2022-08-02T04:52:22.267132Z","iopub.status.idle":"2022-08-02T04:52:22.277498Z","shell.execute_reply.started":"2022-08-02T04:52:22.267098Z","shell.execute_reply":"2022-08-02T04:52:22.276158Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Exploratory Data Analysis","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize = [12,8])\nsns.countplot(x='event', data=df, palette=\"pastel\")","metadata":{"execution":{"iopub.status.busy":"2022-08-02T04:54:29.316483Z","iopub.execute_input":"2022-08-02T04:54:29.316863Z","iopub.status.idle":"2022-08-02T04:54:29.535327Z","shell.execute_reply.started":"2022-08-02T04:54:29.316833Z","shell.execute_reply":"2022-08-02T04:54:29.534274Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = [12,7])\nsns.countplot(x='event_attributes', data=df, palette=\"pastel\")\nplt.xticks(rotation = 50) ","metadata":{"execution":{"iopub.status.busy":"2022-08-02T04:57:06.865900Z","iopub.execute_input":"2022-08-02T04:57:06.866366Z","iopub.status.idle":"2022-08-02T04:57:07.158300Z","shell.execute_reply.started":"2022-08-02T04:57:06.866325Z","shell.execute_reply":"2022-08-02T04:57:07.157235Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = [15,8])\ndf['event'].value_counts().plot(kind='barh')","metadata":{"execution":{"iopub.status.busy":"2022-08-02T04:58:54.277740Z","iopub.execute_input":"2022-08-02T04:58:54.278478Z","iopub.status.idle":"2022-08-02T04:58:54.478167Z","shell.execute_reply.started":"2022-08-02T04:58:54.278440Z","shell.execute_reply":"2022-08-02T04:58:54.477452Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = [15,8])\ndf['event_attributes'].value_counts().plot(kind='barh')","metadata":{"execution":{"iopub.status.busy":"2022-08-02T04:59:02.847192Z","iopub.execute_input":"2022-08-02T04:59:02.847947Z","iopub.status.idle":"2022-08-02T04:59:03.065704Z","shell.execute_reply.started":"2022-08-02T04:59:02.847912Z","shell.execute_reply":"2022-08-02T04:59:03.064539Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize = (12, 7))\nplt.bar(df.event, df.event_attributes, color ='green',\n        width = 0.4)","metadata":{"execution":{"iopub.status.busy":"2022-08-02T05:05:40.717318Z","iopub.execute_input":"2022-08-02T05:05:40.718445Z","iopub.status.idle":"2022-08-02T05:05:59.367028Z","shell.execute_reply.started":"2022-08-02T05:05:40.718401Z","shell.execute_reply":"2022-08-02T05:05:59.366003Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(8,6), dpi=100)\nplt.title('Histogram of the Time Column')\nsns.histplot(df['time'], bins=30, kde=True)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T05:08:06.969258Z","iopub.execute_input":"2022-08-02T05:08:06.970502Z","iopub.status.idle":"2022-08-02T05:08:07.441048Z","shell.execute_reply.started":"2022-08-02T05:08:06.970440Z","shell.execute_reply":"2022-08-02T05:08:07.440004Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(10,7), dpi=100)\nplt.xticks(rotation=90)\nsns.countplot(data=df, x='video_id', hue='event', hue_order=['play', 'start', 'end', 'challenge', 'throwin'], palette='inferno')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T05:08:30.213332Z","iopub.execute_input":"2022-08-02T05:08:30.213724Z","iopub.status.idle":"2022-08-02T05:08:30.688944Z","shell.execute_reply.started":"2022-08-02T05:08:30.213695Z","shell.execute_reply":"2022-08-02T05:08:30.687772Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['video_id'].unique()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T05:11:15.817474Z","iopub.execute_input":"2022-08-02T05:11:15.817870Z","iopub.status.idle":"2022-08-02T05:11:15.825382Z","shell.execute_reply.started":"2022-08-02T05:11:15.817840Z","shell.execute_reply":"2022-08-02T05:11:15.824746Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"full_length_videos = [\"1606b0e6_0\", \"1606b0e6_1\", \"35bd9041_0\", \"35bd9041_1\", \"3c993bd2_0\", \"3c993bd2_1\", \"cfbe2e94_0\", \"cfbe2e94_1\"]\nfull_length_videos  = str(\"|\".join(full_length_videos))","metadata":{"execution":{"iopub.status.busy":"2022-08-02T05:11:29.014385Z","iopub.execute_input":"2022-08-02T05:11:29.015334Z","iopub.status.idle":"2022-08-02T05:11:29.020565Z","shell.execute_reply.started":"2022-08-02T05:11:29.015280Z","shell.execute_reply":"2022-08-02T05:11:29.019559Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"full_length_df = df[df['video_id'].str.contains(full_length_videos)]","metadata":{"execution":{"iopub.status.busy":"2022-08-02T05:11:38.253742Z","iopub.execute_input":"2022-08-02T05:11:38.254114Z","iopub.status.idle":"2022-08-02T05:11:38.268350Z","shell.execute_reply.started":"2022-08-02T05:11:38.254085Z","shell.execute_reply":"2022-08-02T05:11:38.267542Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"full_length_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T05:11:53.064503Z","iopub.execute_input":"2022-08-02T05:11:53.064955Z","iopub.status.idle":"2022-08-02T05:11:53.077897Z","shell.execute_reply.started":"2022-08-02T05:11:53.064919Z","shell.execute_reply":"2022-08-02T05:11:53.076678Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"challange_df = df[df[\"event\"] == \"challenge\"]\nchallange_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T05:14:47.840410Z","iopub.execute_input":"2022-08-02T05:14:47.840780Z","iopub.status.idle":"2022-08-02T05:14:47.856029Z","shell.execute_reply.started":"2022-08-02T05:14:47.840751Z","shell.execute_reply":"2022-08-02T05:14:47.855286Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data = challange_df, y = \"event_attributes\")","metadata":{"execution":{"iopub.status.busy":"2022-08-02T05:15:03.361728Z","iopub.execute_input":"2022-08-02T05:15:03.362106Z","iopub.status.idle":"2022-08-02T05:15:03.606490Z","shell.execute_reply.started":"2022-08-02T05:15:03.362077Z","shell.execute_reply":"2022-08-02T05:15:03.605442Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"throwin_df = df[df[\"event\"] == \"throwin\"]\nthrowin_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T05:16:17.808663Z","iopub.execute_input":"2022-08-02T05:16:17.809056Z","iopub.status.idle":"2022-08-02T05:16:17.821839Z","shell.execute_reply.started":"2022-08-02T05:16:17.809021Z","shell.execute_reply":"2022-08-02T05:16:17.821062Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data = throwin_df, y = \"event_attributes\")","metadata":{"execution":{"iopub.status.busy":"2022-08-02T05:16:19.843993Z","iopub.execute_input":"2022-08-02T05:16:19.844498Z","iopub.status.idle":"2022-08-02T05:16:20.014938Z","shell.execute_reply.started":"2022-08-02T05:16:19.844452Z","shell.execute_reply":"2022-08-02T05:16:20.014010Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"play_df = df[df[\"event\"] == \"play\"]\nplay_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T05:16:22.514358Z","iopub.execute_input":"2022-08-02T05:16:22.514729Z","iopub.status.idle":"2022-08-02T05:16:22.528063Z","shell.execute_reply.started":"2022-08-02T05:16:22.514701Z","shell.execute_reply":"2022-08-02T05:16:22.527079Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data = play_df, y = \"event_attributes\")","metadata":{"execution":{"iopub.status.busy":"2022-08-02T05:16:24.562505Z","iopub.execute_input":"2022-08-02T05:16:24.563193Z","iopub.status.idle":"2022-08-02T05:16:24.755062Z","shell.execute_reply.started":"2022-08-02T05:16:24.563158Z","shell.execute_reply":"2022-08-02T05:16:24.754338Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(10,7))\nsns.barplot(data=df, x='event', y='time')\nplt.title('Time distribution by event type')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T05:24:09.945837Z","iopub.execute_input":"2022-08-02T05:24:09.947059Z","iopub.status.idle":"2022-08-02T05:24:10.427902Z","shell.execute_reply.started":"2022-08-02T05:24:09.947003Z","shell.execute_reply":"2022-08-02T05:24:10.426742Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,6))\nsns.barplot(data=df, x='event_attributes', y='time')\nplt.title('Time distribution by event atrributes type')\nplt.xticks(rotation=90)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T05:25:52.714659Z","iopub.execute_input":"2022-08-02T05:25:52.715369Z","iopub.status.idle":"2022-08-02T05:25:53.517403Z","shell.execute_reply.started":"2022-08-02T05:25:52.715315Z","shell.execute_reply":"2022-08-02T05:25:53.516333Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,6))\nsns.barplot(data=df, x='video_id', y='time')\nplt.title('Time distribution by video')\nplt.xticks(rotation=90)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T05:26:38.794701Z","iopub.execute_input":"2022-08-02T05:26:38.795092Z","iopub.status.idle":"2022-08-02T05:26:39.479563Z","shell.execute_reply.started":"2022-08-02T05:26:38.795061Z","shell.execute_reply":"2022-08-02T05:26:39.478810Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"video_df = play_df.groupby(by=[\"video_id\"], )[\"time\"].sum().to_frame().reset_index()\nvideo_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-02T05:21:57.008444Z","iopub.execute_input":"2022-08-02T05:21:57.008867Z","iopub.status.idle":"2022-08-02T05:21:57.023127Z","shell.execute_reply.started":"2022-08-02T05:21:57.008831Z","shell.execute_reply":"2022-08-02T05:21:57.022278Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"more to follow....","metadata":{},"execution_count":null,"outputs":[]}]}