text_html_output_1.png
import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import plotly.express as px

articles = pd.read_csv('/kaggle/input/h-and-m-personalized-fashion-recommendations/articles.csv')

customers = pd.read_csv('/kaggle/input/h-and-m-personalized-fashion-recommendations/customers.csv')

transactions = pd.read_csv('/kaggle/input/h-and-m-personalized-fashion-recommendations/transactions_train.csv')

def missing_values(data):
    total = data.isnull().sum().sort_values(ascending=False)
    percent = (data.isnull().sum() / data.isnull().count() * 100).sort_values(ascending=False)
    return pd.concat([total, percent], axis=1, keys=['Number of Missing Values', 'Percentage'])

fig = px.pie(articles, values='article_id', 
             title='Distribution by Index Group Name',
             names='index_group_name',
             color_discrete_sequence=px.colors.sequential.RdBu,
             hover_data=['index_group_name'],
             labels={'index_group_name':'Index Group Name'},
            height=450)
fig.show()

fig = px.histogram(articles, x='garment_group_name',color="index_group_name", 
                   title="Index Group Name per Garment Group Name",
                  color_discrete_sequence=px.colors.sequential.Agsunset,
                  height=600)
fig.show()

df1 = articles.groupby(["section_name"]).count().reset_index()

fig = px.bar(df1,
             x=articles.groupby(["section_name"]).size(),
             y="section_name",
             color='section_name',
             title='Distribution by Section Name',
             hover_data=['section_name'],
             text_auto='.2s',
             labels={'section_name':'Section Name'},
             orientation='h',
             color_discrete_sequence=px.colors.diverging.Temps,         
             height=1000)
fig.update_traces(textfont_size=11, textangle=0, textposition="outside", cliponaxis=False)
fig.update_layout(xaxis_title = 'Count')
fig.show()

df4= articles.groupby(["index_name"])["article_id"].nunique()
df4 = pd.DataFrame({'IndexName': df4.index,
                   'Articles': df4.values
                  })
labels=df4['IndexName']
values=df4['Articles']
fig = px.pie(labels, values = values, hole = 0.35,
              names = labels,
              title = 'Distribution by Index Name',
              color_discrete_sequence =px.colors.cyclical.mygbm
              )
fig.show()

df5 = articles.groupby(['perceived_colour_master_name']).count().reset_index()
colors = ['#F5F5DC', '#000000', '#023e8a', '#168aad', '#7f5539', '#90be6d', '#b7b7a4', '#606c38', '#9d4edd', '#b7b7a4', '#9e2a2b', '#f77f00', '#ffafcc', '#d00000', '#34a0a4', '#3e1f47', '#ffffff', '#fcbf49', '#dddf00', '#9e0059']
fig = px.bar(df5, y=articles.groupby(['perceived_colour_master_name']).size(), x='perceived_colour_master_name', color='perceived_colour_master_name', hover_data=['perceived_colour_master_name'], text_auto='.2s', color_discrete_sequence=colors, title='Distribution by Percieved Color Master Name', labels={'perceived_colour_master_name': 'Percieved Color Master Name'})
fig.update_traces(textfont_size=11, textangle=0, textposition='outside', cliponaxis=False)
fig.update_layout(yaxis_title='Count')
fig.show()