File size: 3,092 Bytes
e1c4c0d
 
1fc8a58
e1c4c0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import pandas as pd
import gradio as gr
#import openpyxl

def compute_mode_openmarket(file):
    # Read the Excel file
    df = pd.read_excel(file)
    opm=df[df['Outlet Channel']=='OPEN MARKET']
    # Compute the mode of each column
    modes = opm.mode()

    # Convert the result to a new Excel file
    modes.to_excel("modes.xlsx", index=False)

    return "modes.xlsx"

def compute_mode_wholesale(file):
    # Read the Excel file
    df = pd.read_excel(file)
    wholesale=df[df['Outlet Channel']=='WHOLESALE']
    # Compute the mode of each column
    modes = wholesale.mode()

    # Convert the result to a new Excel file
    modes.to_excel("modes.xlsx", index=False)

    return "modes.xlsx"

def compute_mode_Large_supermarkets(file):
    # Read the Excel file
    df = pd.read_excel(file)
    opm=df[df['Outlet Channel']=='Large supermarkets']
    # Compute the mode of each column
    modes = opm.mode()

    # Convert the result to a new Excel file
    modes.to_excel("modes.xlsx", index=False)

    return "modes.xlsx"

def compute_mode_Small_Supermarkets(file):
    # Read the Excel file
    df = pd.read_excel(file)
    opm=df[df['Outlet Channel']=='Small Supermarkets']
    # Compute the mode of each column
    modes = opm.mode()

    # Convert the result to a new Excel file
    modes.to_excel("modes.xlsx", index=False)

    return "modes.xlsx"

def compute_mode_Neighbourhood_grocery(file):
    # Read the Excel file
    df = pd.read_excel(file)
    opm=df[df['Outlet Channel']=='Neighbourhood grocery']
    # Compute the mode of each column
    modes = opm.mode()

    # Convert the result to a new Excel file
    modes.to_excel("modes.xlsx", index=False)

    return "modes.xlsx"

# Create a Gradio interface
inputs = gr.File(label="Upload Excel File")
outputs = gr.File(label="Download Mode File")
iface1 = gr.Interface(fn=compute_mode_openmarket, inputs=inputs, outputs=outputs, title="Excel Mode Calculator")

# Create a Gradio interface
inputs = gr.File(label="Upload Excel File")
outputs = gr.File(label="Download Mode File")
iface2 = gr.Interface(fn=compute_mode_wholesale, inputs=inputs, outputs=outputs, title="Excel Mode Calculator")

# Create a Gradio interface
inputs = gr.File(label="Upload Excel File")
outputs = gr.File(label="Download Mode File")
iface3 = gr.Interface(fn=compute_mode_Small_Supermarkets, inputs=inputs, outputs=outputs, title="Excel Mode Calculator")

# Create a Gradio interface
inputs = gr.File(label="Upload Excel File")
outputs = gr.File(label="Download Mode File")
iface4 = gr.Interface(fn=compute_mode_Large_supermarkets, inputs=inputs, outputs=outputs, title="Excel Mode Calculator")

# Create a Gradio interface
inputs = gr.File(label="Upload Excel File")
outputs = gr.File(label="Download Mode File")
iface5 = gr.Interface(fn=compute_mode_Neighbourhood_grocery, inputs=inputs, outputs=outputs, title="Excel Mode Calculator")

# Launch the interface
gr.TabbedInterface([iface1,iface2,iface3,iface4,iface5],tab_names=['Open Market','Wholesale','Small Supermarkets','Large Supermarkets','Neighbourhood Grocery']).launch(share=True)