{"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 required libraries\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-03-01T11:56:38.475177Z","iopub.execute_input":"2022-03-01T11:56:38.475701Z","iopub.status.idle":"2022-03-01T11:56:38.480725Z","shell.execute_reply.started":"2022-03-01T11:56:38.475661Z","shell.execute_reply":"2022-03-01T11:56:38.480010Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Load the dataset - articles into the dataframe\narticles=pd.read_csv(\"../input/h-and-m-personalized-fashion-recommendations/articles.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-03-01T11:56:38.482423Z","iopub.execute_input":"2022-03-01T11:56:38.482904Z","iopub.status.idle":"2022-03-01T11:56:39.167913Z","shell.execute_reply.started":"2022-03-01T11:56:38.482866Z","shell.execute_reply":"2022-03-01T11:56:39.166755Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Display first 5 rows\narticles.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-01T11:56:39.169309Z","iopub.execute_input":"2022-03-01T11:56:39.169607Z","iopub.status.idle":"2022-03-01T11:56:39.201868Z","shell.execute_reply.started":"2022-03-01T11:56:39.169571Z","shell.execute_reply":"2022-03-01T11:56:39.201044Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Check the types of data\narticles.info()","metadata":{"execution":{"iopub.status.busy":"2022-03-01T11:56:39.203130Z","iopub.execute_input":"2022-03-01T11:56:39.203591Z","iopub.status.idle":"2022-03-01T11:56:39.356553Z","shell.execute_reply.started":"2022-03-01T11:56:39.203560Z","shell.execute_reply":"2022-03-01T11:56:39.355460Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Summary of the numerical features\narticles.describe()","metadata":{"execution":{"iopub.status.busy":"2022-03-01T11:56:39.359826Z","iopub.execute_input":"2022-03-01T11:56:39.360277Z","iopub.status.idle":"2022-03-01T11:56:39.440410Z","shell.execute_reply.started":"2022-03-01T11:56:39.360226Z","shell.execute_reply":"2022-03-01T11:56:39.439201Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Total number of rows and columns\narticles.shape","metadata":{"execution":{"iopub.status.busy":"2022-03-01T11:56:39.442489Z","iopub.execute_input":"2022-03-01T11:56:39.442842Z","iopub.status.idle":"2022-03-01T11:56:39.451391Z","shell.execute_reply.started":"2022-03-01T11:56:39.442792Z","shell.execute_reply":"2022-03-01T11:56:39.450453Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Rows containing duplicate data\ndupli_rows = articles[articles.duplicated()]\nprint(\"Number of duplicate rows: \", dupli_rows.shape)","metadata":{"execution":{"iopub.status.busy":"2022-03-01T11:56:39.452622Z","iopub.execute_input":"2022-03-01T11:56:39.452878Z","iopub.status.idle":"2022-03-01T11:56:39.689195Z","shell.execute_reply.started":"2022-03-01T11:56:39.452845Z","shell.execute_reply":"2022-03-01T11:56:39.688217Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# how many null-na  values in each column\narticles.isna().sum()  ","metadata":{"execution":{"iopub.status.busy":"2022-03-01T11:56:39.690390Z","iopub.execute_input":"2022-03-01T11:56:39.690634Z","iopub.status.idle":"2022-03-01T11:56:39.832861Z","shell.execute_reply.started":"2022-03-01T11:56:39.690605Z","shell.execute_reply":"2022-03-01T11:56:39.832098Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Feature detail_desc is having null values","metadata":{}},{"cell_type":"code","source":"# Dealing null values with mode\narticles.detail_desc.fillna(articles.detail_desc.mode()[0],inplace = True) ","metadata":{"execution":{"iopub.status.busy":"2022-03-01T11:56:39.833921Z","iopub.execute_input":"2022-03-01T11:56:39.834753Z","iopub.status.idle":"2022-03-01T11:56:39.883388Z","shell.execute_reply.started":"2022-03-01T11:56:39.834705Z","shell.execute_reply":"2022-03-01T11:56:39.882589Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Unique product types\narticles.product_type_no.unique()","metadata":{"execution":{"iopub.status.busy":"2022-03-01T11:56:39.884629Z","iopub.execute_input":"2022-03-01T11:56:39.885004Z","iopub.status.idle":"2022-03-01T11:56:39.892561Z","shell.execute_reply.started":"2022-03-01T11:56:39.884974Z","shell.execute_reply":"2022-03-01T11:56:39.891821Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Unique product types\nproduct_count=articles[\"product_type_no\"].value_counts()\n","metadata":{"execution":{"iopub.status.busy":"2022-03-01T11:56:39.893689Z","iopub.execute_input":"2022-03-01T11:56:39.894163Z","iopub.status.idle":"2022-03-01T11:56:39.903004Z","shell.execute_reply.started":"2022-03-01T11:56:39.894006Z","shell.execute_reply":"2022-03-01T11:56:39.902215Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# assigned index to each product\nproduct_count.index","metadata":{"execution":{"iopub.status.busy":"2022-03-01T11:56:39.904326Z","iopub.execute_input":"2022-03-01T11:56:39.904578Z","iopub.status.idle":"2022-03-01T11:56:39.917797Z","shell.execute_reply.started":"2022-03-01T11:56:39.904547Z","shell.execute_reply":"2022-03-01T11:56:39.916715Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Groupby Product\nby_product=articles.groupby(\"product_type_no\")\nby_product.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-01T11:56:39.919079Z","iopub.execute_input":"2022-03-01T11:56:39.919424Z","iopub.status.idle":"2022-03-01T11:56:39.967315Z","shell.execute_reply.started":"2022-03-01T11:56:39.919384Z","shell.execute_reply":"2022-03-01T11:56:39.966310Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"by_product.count()","metadata":{"execution":{"iopub.status.busy":"2022-03-01T11:56:39.970944Z","iopub.execute_input":"2022-03-01T11:56:39.971559Z","iopub.status.idle":"2022-03-01T11:56:40.169373Z","shell.execute_reply.started":"2022-03-01T11:56:39.971525Z","shell.execute_reply":"2022-03-01T11:56:40.168255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# By_Product type \nby_product.sum().to_csv(\"Product Types.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-03-01T11:56:40.170821Z","iopub.execute_input":"2022-03-01T11:56:40.171174Z","iopub.status.idle":"2022-03-01T11:56:40.192210Z","shell.execute_reply.started":"2022-03-01T11:56:40.171126Z","shell.execute_reply":"2022-03-01T11:56:40.191053Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(20, 15), dpi=80)\nplt.hist(articles[\"product_type_no\"])","metadata":{"execution":{"iopub.status.busy":"2022-03-01T11:56:40.193593Z","iopub.execute_input":"2022-03-01T11:56:40.193892Z","iopub.status.idle":"2022-03-01T11:56:40.544408Z","shell.execute_reply.started":"2022-03-01T11:56:40.193859Z","shell.execute_reply":"2022-03-01T11:56:40.543377Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}}]}