From bf62714d434fecc8b68dddf346601035a288f5b6 Mon Sep 17 00:00:00 2001 From: amilashanaka <dsa.amilashanaka@gmail.com> Date: Wed, 30 Nov 2022 19:15:04 +0000 Subject: [PATCH] Product Category - Data Frequency --- model.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/model.py b/model.py index 47326fc..60baa90 100644 --- a/model.py +++ b/model.py @@ -68,3 +68,44 @@ plt.ylabel("Product Category") plt.title("Product Category - Data Frequency") plt.show() print(f"Number of ProductCategory \n{data['ProductCategory'].value_counts()}") + + +# Number of samples according to Warehouse +sns.countplot(x="Warehouse", data=data) +plt.xticks(rotation = 0) +plt.show() +print(f"Number of samples according to Warehouse \n{data['Warehouse'].value_counts()}") + +sns.catplot(x="Month", y="OrderDemand", hue="Year", col="Warehouse", + data=data, kind="bar", height=4) +plt.show() + +sns.violinplot(x="Year", y="OrderDemand", data=data) +plt.show() + +df = data[['OrderDemand', 'Year']].groupby(["Year"]).sum().reset_index().sort_values(by='Year', ascending=False) +f, ax=plt.subplots(figsize=(15, 5)) +sns.pointplot(x='Year', y='OrderDemand', data=df) +plt.show() + + +plt.pie(df['OrderDemand'], labels=df['Year'].unique(), autopct='%1.2f%%') +plt.show() + +temp_data = data.copy() +temp_data.Month.replace([1,2,3,4,5,6,7,8,9,10,11,12], ['Jan', 'Feb', 'Mar', 'Apr', 'May', + 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], inplace=True) +df = temp_data[['OrderDemand', + 'Month', 'Year',]].groupby(["Year", + "Month"]).sum().reset_index().sort_values(by=['Year', + 'Month'], ascending=False) +f, ax=plt.subplots(figsize=(15, 5)) +sns.pointplot(x='Year', y='OrderDemand', data=df, hue='Month', hue_order=['Jan', 'Feb', 'Mar', 'Apr', 'May', + 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']) +plt.show() + + +# Monthly pivot table +df = (df.pivot(index='Year', columns='Month', values='OrderDemand')) +df = df.loc[:, ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']] +df \ No newline at end of file -- GitLab