{"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 os, path\n\nimport matplotlib\nimport matplotlib.pyplot as plt\nimport matplotlib.pylab as pylab\nimport seaborn as sns\n\n%matplotlib inline\nmatplotlib.style.use(\"ggplot\")\n\nimport plotly.express as px\nimport plotly.graph_objects as go\nfrom plotly.subplots import make_subplots\n\nDATA_DIR = path.Path('../input/hotel-id-2021-fgvc8')","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Train data set","metadata":{}},{"cell_type":"code","source":"df_train = pd.read_csv(DATA_DIR.joinpath(\"train.csv\"))\ndf_train[\"timestamp\"] = pd.to_datetime(df_train[\"timestamp\"])","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Size of the training set","metadata":{}},{"cell_type":"code","source":"print(f\"Training set contains { df_train.shape[0]} rows\") ","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# when were the pictures collected?","metadata":{}},{"cell_type":"code","source":"# possible improvements: plot multiple colors for different chains\n\nplt.figure(figsize=(20,4))\ndf_train\\\n    .set_index(\"timestamp\")\\\n    .sort_index()[\"image\"]\\\n    .resample('d').count().plot()\n\nplt.show()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## How many hotels in each chain","metadata":{}},{"cell_type":"code","source":"df_train.head()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_hotel_cnt = df_train.groupby(\"chain\").nunique()[\"hotel_id\"].rename(\"num_hotels\")\n\npx.bar(data_frame=df_hotel_cnt, y=\"num_hotels\")","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## How many pictures per hotel?","metadata":{}},{"cell_type":"code","source":"df_img_cnt = df_train.groupby([\"hotel_id\", \"chain\"]).count()[\"timestamp\"].rename(\"num_images\").reset_index()\n\npx.box(\n    df_img_cnt,\n    x=\"chain\",\n    y=\"num_images\"\n)","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}