etorqweku commited on
Commit
fc4fcb6
·
1 Parent(s): e7475b6
Files changed (2) hide show
  1. app.py +90 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import gradio as gr
3
+
4
+ def compute_mode_openmarket(file):
5
+ # Read the Excel file
6
+ df = pd.read_excel(file)
7
+ opm=df[df['Outlet Channel']=='OPEN MARKET']
8
+ # Compute the mode of each column
9
+ modes = opm.mode()
10
+
11
+ # Convert the result to a new Excel file
12
+ modes.to_excel("modes.xlsx", index=False)
13
+
14
+ return "modes.xlsx"
15
+
16
+ def compute_mode_wholesale(file):
17
+ # Read the Excel file
18
+ df = pd.read_excel(file)
19
+ wholesale=df[df['Outlet Channel']=='WHOLESALE']
20
+ # Compute the mode of each column
21
+ modes = wholesale.mode()
22
+
23
+ # Convert the result to a new Excel file
24
+ modes.to_excel("modes.xlsx", index=False)
25
+
26
+ return "modes.xlsx"
27
+
28
+ def compute_mode_Large_supermarkets(file):
29
+ # Read the Excel file
30
+ df = pd.read_excel(file)
31
+ opm=df[df['Outlet Channel']=='Large supermarkets']
32
+ # Compute the mode of each column
33
+ modes = opm.mode()
34
+
35
+ # Convert the result to a new Excel file
36
+ modes.to_excel("modes.xlsx", index=False)
37
+
38
+ return "modes.xlsx"
39
+
40
+ def compute_mode_Small_Supermarkets(file):
41
+ # Read the Excel file
42
+ df = pd.read_excel(file)
43
+ opm=df[df['Outlet Channel']=='Small Supermarkets']
44
+ # Compute the mode of each column
45
+ modes = opm.mode()
46
+
47
+ # Convert the result to a new Excel file
48
+ modes.to_excel("modes.xlsx", index=False)
49
+
50
+ return "modes.xlsx"
51
+
52
+ def compute_mode_Neighbourhood_grocery(file):
53
+ # Read the Excel file
54
+ df = pd.read_excel(file)
55
+ opm=df[df['Outlet Channel']=='Neighbourhood grocery']
56
+ # Compute the mode of each column
57
+ modes = opm.mode()
58
+
59
+ # Convert the result to a new Excel file
60
+ modes.to_excel("modes.xlsx", index=False)
61
+
62
+ return "modes.xlsx"
63
+
64
+ # Create a Gradio interface
65
+ inputs = gr.File(label="Upload Excel File")
66
+ outputs = gr.File(label="Download Mode File")
67
+ iface1 = gr.Interface(fn=compute_mode_openmarket, inputs=inputs, outputs=outputs, title="Excel Mode Calculator")
68
+
69
+ # Create a Gradio interface
70
+ inputs = gr.File(label="Upload Excel File")
71
+ outputs = gr.File(label="Download Mode File")
72
+ iface2 = gr.Interface(fn=compute_mode_wholesale, inputs=inputs, outputs=outputs, title="Excel Mode Calculator")
73
+
74
+ # Create a Gradio interface
75
+ inputs = gr.File(label="Upload Excel File")
76
+ outputs = gr.File(label="Download Mode File")
77
+ iface3 = gr.Interface(fn=compute_mode_Small_Supermarkets, inputs=inputs, outputs=outputs, title="Excel Mode Calculator")
78
+
79
+ # Create a Gradio interface
80
+ inputs = gr.File(label="Upload Excel File")
81
+ outputs = gr.File(label="Download Mode File")
82
+ iface4 = gr.Interface(fn=compute_mode_Large_supermarkets, inputs=inputs, outputs=outputs, title="Excel Mode Calculator")
83
+
84
+ # Create a Gradio interface
85
+ inputs = gr.File(label="Upload Excel File")
86
+ outputs = gr.File(label="Download Mode File")
87
+ iface5 = gr.Interface(fn=compute_mode_Neighbourhood_grocery, inputs=inputs, outputs=outputs, title="Excel Mode Calculator")
88
+
89
+ # Launch the interface
90
+ gr.TabbedInterface([iface1,iface2,iface3,iface4,iface5],tab_names=['Open Market','Wholesale','Small Supermarkets','Large Supermarkets','Neighbourhood Grocery']).launch(share=True)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio==4.27.0
2
+ pandas==2.2.2
3
+ openpylx==3.1.2