Chitranshu commited on
Commit
d2f4246
·
0 Parent(s):

Duplicate from Chitranshu/Dashboard-Dmart

Browse files
Files changed (7) hide show
  1. .gitattributes +35 -0
  2. DMart.csv +0 -0
  3. Dmart.png +0 -0
  4. Dockerfile +16 -0
  5. README.md +11 -0
  6. app.py +166 -0
  7. requirements.txt +7 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
DMart.csv ADDED
The diff for this file is too large to render. See raw diff
 
Dmart.png ADDED
Dockerfile ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ WORKDIR /code
4
+
5
+ COPY ./requirements.txt /code/requirements.txt
6
+ RUN python3 -m pip install --no-cache-dir --upgrade pip
7
+ RUN python3 -m pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
+
9
+ COPY . .
10
+
11
+ CMD ["panel", "serve", "/code/app.py", "--address", "0.0.0.0", "--port", "7860", "--allow-websocket-origin", "*"]
12
+
13
+ RUN mkdir /.cache
14
+ RUN chmod 777 /.cache
15
+ RUN mkdir .chroma
16
+ RUN chmod 777 .chroma
README.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Dmart-Dashboard
3
+ emoji: 📊
4
+ colorFrom: green
5
+ colorTo: green
6
+ sdk: docker
7
+ pinned: false
8
+ duplicated_from: Chitranshu/Dashboard-Dmart
9
+ ---
10
+
11
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import numpy as np
3
+ import panel as pn
4
+ pn.extension('tabulator')
5
+
6
+ import hvplot.pandas
7
+
8
+ project_data = pd.read_csv(r'DMart.csv')
9
+ project_data.columns
10
+ project_data.info()
11
+ project_data.describe()
12
+ project_data.isna().sum()
13
+ project_data.shape
14
+ project_data['Brand'] = project_data['Brand'].fillna('others')
15
+ project_data.isna().sum()
16
+ project_data = project_data.dropna()
17
+ project_data.isna().sum()
18
+ df = pd.DataFrame(project_data)
19
+ idf = df.interactive()
20
+ df.groupby(by=["SubCategory","Quantity"], dropna=False, sort=True).sum()
21
+ import pandas as pd
22
+ import panel as pn
23
+ import hvplot.pandas
24
+ import seaborn as sns
25
+ import pandas as pd
26
+ import seaborn as sns
27
+ import hvplot.pandas
28
+ import panel as pn
29
+
30
+ # Assuming your dataset is stored in a DataFrame called 'df'
31
+
32
+ # Create an interactive DataFrame
33
+ idf = df.interactive()
34
+
35
+ # Define Panel widgets for Top 10 Brands and Top 10 Categories
36
+ brand_count = df['Brand'].value_counts().nlargest(10)
37
+ category_count = df['Category'].value_counts().nlargest(10)
38
+
39
+ # Define the hvplot charts with increased size
40
+ brand_chart = brand_count.hvplot.bar(rot=90, title='Top 10 Brands', color=['#206b33'], width=800, height=400) # Different shades of green
41
+ category_chart = category_count.hvplot.bar(rot=90, title='Top 10 Categories', color=['#206b33'], width=800, height=400)
42
+
43
+ # Create brand_price and category_price dictionaries
44
+ brand_price = {}
45
+ category_price = {}
46
+
47
+ def brand_and_top_price():
48
+ for index, row in project_data.iterrows():
49
+ if row["Brand"] in brand_price:
50
+ if brand_price.get(row["Brand"]) < row["Price"]:
51
+ brand_price[row["Brand"]] = row["Price"]
52
+ else:
53
+ brand_price[row["Brand"]] = row["Price"]
54
+
55
+ def category_and_top_price():
56
+ for index, row in project_data.iterrows():
57
+ if row["Category"] in category_price:
58
+ if category_price.get(row["Category"]) < row["Price"]:
59
+ category_price[row["Category"]] = row["Price"]
60
+ else:
61
+ category_price[row["Category"]] = row["Price"]
62
+
63
+ brand_and_top_price()
64
+ category_and_top_price()
65
+ project_data_interactive = project_data.interactive()
66
+ idf = df.interactive()
67
+
68
+ # Define Panel widgets
69
+ category_1 = project_data['Category'].value_counts().nlargest(10)
70
+ brand_1 = project_data["Brand"].value_counts().nlargest(15).sort_values(ascending=False)
71
+ # Define the hvplot charts
72
+ category_chart1 = category_1.hvplot.bar(rot=90, title='Category Distribution', color=['#206b33'], width=800, height=400)
73
+ brand_chart1 = brand_1.hvplot.bar(rot=90, title='Brand Count Distribution (Top 15)', color=['#206b33'], width=800, height=400)
74
+ price_chart = df.hvplot(y='Price', color='#006400', width=800, height=400)
75
+ discounted_price_chart = df.hvplot(y='DiscountedPrice', color='#006400', width=800, height=400)
76
+ brand_price = dict(sorted(brand_price.items(), key=lambda item: item[1], reverse=True))
77
+ category_price = dict(sorted(category_price.items(), key=lambda item: item[1], reverse=True))
78
+
79
+ df_brand = pd.DataFrame(brand_price.items(), columns=['Brand', 'Price']).head(20)
80
+ df_category = pd.DataFrame(category_price.items(), columns=['Category', 'Price']).head(20)
81
+
82
+ # Create a reversed green color palette
83
+ green_palette = sns.color_palette('Greens', n_colors=20)
84
+ reversed_palette = list(reversed(green_palette))
85
+
86
+ # Create brand bar chart using hvPlot
87
+ brand_price_chart = df_brand.hvplot.bar(x='Brand', y='Price', rot=90, color=reversed_palette,
88
+ title='Top Price in Every Brand', xlabel='Brand', ylabel='Price',
89
+ width=800, height=400)
90
+
91
+ # Create category bar chart using hvPlot
92
+ category_price_chart = df_category.hvplot.bar(x='Category', y='Price', rot=90, color=green_palette[::-1],
93
+ title='Top Price in Every Category', xlabel='Category', ylabel='Price',
94
+ width=800, height=400)
95
+
96
+ # Define Panel widgets
97
+ yaxis_radio = pn.widgets.RadioButtonGroup(
98
+ name='Y axis',
99
+ options=['Top 10 Brands', 'Top 10 Categories', 'Top Price Brands', 'Top Price Categories', 'Category Distribution', 'Brand Count Distribution', 'Price', 'DiscountedPrice'],
100
+ button_type='success',
101
+ inline=True
102
+ )
103
+
104
+ # Define the Panel layout
105
+ panel_layout = pn.Column(
106
+ yaxis_radio
107
+ )
108
+
109
+ # Define the callback function for the radio button
110
+ def update_chart(event):
111
+ if event.new == 'Top 10 Brands':
112
+ panel_layout[1:] = [brand_chart]
113
+ elif event.new == 'Top 10 Categories':
114
+ panel_layout[1:] = [category_chart]
115
+ elif event.new == 'Top Price Brands':
116
+ panel_layout[1:] = [brand_price_chart]
117
+ elif event.new == 'Top Price Categories':
118
+ panel_layout[1:] = [category_price_chart]
119
+ elif event.new == 'Category Distribution':
120
+ panel_layout[1:] = [category_chart1]
121
+ elif event.new == 'Brand Count Distribution':
122
+ panel_layout[1:] = [brand_chart1]
123
+ elif event.new == 'Price':
124
+ panel_layout[1:] = [price_chart]
125
+ elif event.new == 'DiscountedPrice':
126
+ panel_layout[1:] = [discounted_price_chart]
127
+
128
+ yaxis_radio.param.watch(update_chart, 'value')
129
+
130
+ # Display the initial chart
131
+ panel_layout.append(brand_chart)
132
+
133
+ # Display the Panel layout
134
+ panel_layout
135
+ dashboard = panel_layout
136
+ import panel as pn
137
+ pn.extension() # Add this line to load the Panel extension
138
+
139
+ # Layout using Template
140
+ template = pn.template.FastListTemplate(
141
+ title='D-mart Products Analysis Dashboard',
142
+ sidebar=[
143
+ pn.pane.PNG('Dmart.png', sizing_mode='scale_both'),
144
+ pn.pane.Markdown("# Key Performance Indicators (KPIs) of the EDA"),
145
+ pn.pane.Markdown("1. Count of Brands: The count of each brand, indicating brand popularity or representation in the dataset."),
146
+ pn.pane.Markdown("2. Count of Prices: The count of different price values, providing insights into price distribution."),
147
+ pn.pane.Markdown("3. Count of Categories: The count of each category, helping understand the distribution of products across categories."),
148
+ pn.pane.Markdown("4. Price Distribution: The density plot shows the distribution of prices, allowing analysis of price ranges and outliers."),
149
+ pn.pane.Markdown("5. Top Price in Every Brand: Identifies the brands with the highest prices, indicating premium or luxury brands."),
150
+ pn.pane.Markdown("6. Top Price in Every Category: Shows the categories with the highest prices, providing insights into expensive product categories."),
151
+ pn.pane.Markdown("7. Grouping and Summarizing: Summarizes the data by grouping based on 'SubCategory' and 'Quantity,' enabling analysis of aggregated metrics."),
152
+ pn.pane.Markdown("8. Price Distribution (Discounted vs. Original): Compares the distributions of discounted and original prices, offering insights into pricing strategies and discounts.")
153
+ ],
154
+ main = [pn.Row(pn.Column(dashboard)),
155
+ pn.Row(pn.pane.Markdown("DMart is a one-stop supermarket chain that aims to offer customers a wide range of basic home and personal products under one roof. Each DMart store stocks home utility products - including food, toiletries, beauty products, garments, kitchenware, bed and bath linen, home appliances and more - available at competitive prices that our customers appreciate. Our core objective is to offer customers good products at great value.DMart was started by Mr. Radhakishan Damani and his family to address the growing needs of the Indian family. From the launch of its first store in Powai in 2002, DMart today has a well-established presence in 327 locations across India. With D-marts mission is to be the lowest priced retailer in the regions we operate, our business continues to grow with new locations planned in more cities.The supermarket chain of DMart stores is owned and operated by Avenue Supermarts Ltd. (ASL). The company has its headquarters in Mumbai.The brands D Mart, D Mart Minimax, D Mart Premia, D Homes, Dutch Harbour, etc are brands owned by ASL.")),
156
+ pn.Row(pn.pane.Markdown("Designed and Developed with ❤️ by Chitranshu Nagdawane © 2023"))
157
+ ],
158
+ accent_base_color="#206b33",
159
+ header_background="#206b33"
160
+ )
161
+
162
+ template.servable()
163
+
164
+
165
+
166
+
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ panel
2
+ jupyter
3
+ numpy
4
+ pandas
5
+ hvplot
6
+ bokeh
7
+ seaborn