Spaces:
Sleeping
Sleeping
Upload 13 files
Browse files- .gitattributes +1 -0
- Dockerfile +16 -0
- Dockerfile copy +23 -0
- Sustainable_Development_Report_2023_(with_indicators)__-2086263501583264136.csv +0 -0
- Untitled.gif +3 -0
- app.py +127 -0
- botm.png +0 -0
- chat2.py +55 -0
- data_storage.db +0 -0
- deep.py +300 -0
- docker-compose.yml +7 -0
- filter.py +317 -0
- requirements.txt +5 -0
- user.png +0 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* 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
|
|
|
|
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
|
36 |
+
Untitled.gif filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9-slim-buster
|
2 |
+
|
3 |
+
# Set the working directory in the container to /app
|
4 |
+
WORKDIR /app
|
5 |
+
|
6 |
+
# Copy the requirements file
|
7 |
+
COPY requirements.txt .
|
8 |
+
|
9 |
+
# Install the dependencies
|
10 |
+
RUN pip install -r requirements.txt
|
11 |
+
|
12 |
+
# Copy the application code
|
13 |
+
COPY . .
|
14 |
+
|
15 |
+
# Run the command to start the app
|
16 |
+
CMD ["python", "app.py"]
|
Dockerfile copy
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9-slim-buster
|
2 |
+
|
3 |
+
# Set the working directory in the container to /app
|
4 |
+
WORKDIR /app
|
5 |
+
|
6 |
+
# Copy the requirements file
|
7 |
+
COPY requirements.txt .
|
8 |
+
|
9 |
+
# Install the dependencies
|
10 |
+
RUN pip install -r requirements.txt
|
11 |
+
|
12 |
+
# Copy the application code
|
13 |
+
COPY . .
|
14 |
+
|
15 |
+
|
16 |
+
# chown all the files to the app user and switch to the app user
|
17 |
+
RUN chown -R app:app /app
|
18 |
+
USER app
|
19 |
+
|
20 |
+
EXPOSE 7860
|
21 |
+
|
22 |
+
# Run app.py when the container launches
|
23 |
+
ENTRYPOINT ["gunicorn", "--bind", "0.0.0.0:7860", "app:app", "--timeout=0", "--workers", "2", "--worker-class", "gthread", "--threads", "3"]
|
Sustainable_Development_Report_2023_(with_indicators)__-2086263501583264136.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
Untitled.gif
ADDED
![]() |
Git LFS Details
|
app.py
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import sqlite3
|
3 |
+
import uuid
|
4 |
+
from datetime import datetime
|
5 |
+
import gradio as gr
|
6 |
+
import pandas as pd
|
7 |
+
import sqlite3
|
8 |
+
from filter import filter_data, sdg_column_mapping
|
9 |
+
from tar import sdg_indicators_mapping, sdg_input_mapping, sdg_formulas_mapping
|
10 |
+
from deep import filter_and_store_data, data , gradio_app, user_latest_data, create_database ,add_indicator, variable_outputs, get_new_ind, user_late_data, update_indicator_dropdown , sign_in, sign_up, fetch_all_data , calculate_indicator
|
11 |
+
from gradio import utils, themes
|
12 |
+
from chat2 import demo
|
13 |
+
import subprocess
|
14 |
+
import time
|
15 |
+
|
16 |
+
# Define a custom HTML component with an iframe to display the Dash app
|
17 |
+
html_component = gr.HTML("<iframe src='http://localhost:55007' width=100% height='1200'></iframe>")
|
18 |
+
|
19 |
+
# Create a Gradio interface with the HTML component
|
20 |
+
iplot = gr.Interface(
|
21 |
+
fn=None, # Set fn to None since we don't need a function
|
22 |
+
inputs=None,
|
23 |
+
outputs=html_component,
|
24 |
+
live=True
|
25 |
+
)
|
26 |
+
|
27 |
+
iface = gr.Interface(
|
28 |
+
fn=sign_in,
|
29 |
+
inputs=[
|
30 |
+
gr.Textbox(label="Username"),
|
31 |
+
gr.Textbox(label="Password", type="password"),
|
32 |
+
],
|
33 |
+
outputs="text",
|
34 |
+
title="Sign In",
|
35 |
+
theme='xiaobaiyuan/theme_brief'
|
36 |
+
)
|
37 |
+
|
38 |
+
iface2 = gr.Interface(
|
39 |
+
fn=sign_up,
|
40 |
+
inputs=[
|
41 |
+
gr.Textbox(label="Username"),
|
42 |
+
gr.Textbox(label="Password", type="password"),
|
43 |
+
gr.Textbox(label="Email", type='email'),
|
44 |
+
],
|
45 |
+
outputs="text",
|
46 |
+
title="Sign Up",
|
47 |
+
theme='xiaobaiyuan/theme_brief'
|
48 |
+
)
|
49 |
+
|
50 |
+
create_database()
|
51 |
+
max_indicators = 15
|
52 |
+
|
53 |
+
with gr.Blocks(visible=True, title="SRL Data Collector", theme='xiaobaiyuan/theme_brief') as ifa:
|
54 |
+
with gr.Row(variant='panel'):
|
55 |
+
username = gr.Textbox(label="Username",visible=False)
|
56 |
+
username2 = gr.Label(label='Username',value=user_late_data())
|
57 |
+
country_dropdown = gr.Dropdown(choices=list(data['Name'].unique()), type="value", label="Country")
|
58 |
+
sdg_dropdown = gr.Dropdown(choices=list(sdg_column_mapping.keys()), type="value", label="SDG Number")
|
59 |
+
initial_sdg = sdg_dropdown.choices[0]
|
60 |
+
with gr.Column(variant='panel'):
|
61 |
+
indicator_dropdown = gr.Dropdown(choices=[update_indicator_dropdown(initial_sdg)], allow_custom_value=True,multiselect=True, interactive=True,type="value", label="Indicator")
|
62 |
+
sdg_dropdown.change(update_indicator_dropdown, sdg_dropdown, indicator_dropdown)
|
63 |
+
with gr.Column(variant='panel'):
|
64 |
+
rows= []
|
65 |
+
for i in range(max_indicators):
|
66 |
+
row = add_indicator(i)
|
67 |
+
row.visible = False
|
68 |
+
rows.append(row)
|
69 |
+
sdg_dropdown.change(variable_outputs, sdg_dropdown, rows)
|
70 |
+
with gr.Row(variant='panel'):
|
71 |
+
save_button = gr.Button("Save")
|
72 |
+
output = gr.HTML(label="Filtered Data")
|
73 |
+
save_button.click(fn=gradio_app, inputs=[username2, country_dropdown, sdg_dropdown, output], outputs=output)
|
74 |
+
app = gr.Blocks(theme='xiaobaiyuan/theme_brief')
|
75 |
+
|
76 |
+
|
77 |
+
with gr.Blocks(theme='xiaobaiyuan/theme_brief') as calo:
|
78 |
+
show = gr.Button("Show me my data!")
|
79 |
+
with gr.Row():
|
80 |
+
user = gr.Label(label="Username")
|
81 |
+
countr = gr.Label(label="Country Name")
|
82 |
+
sdg = gr.Label(label="SDG Number")
|
83 |
+
with gr.Row():
|
84 |
+
indi = gr.Label(label="Indicator")
|
85 |
+
name = gr.Label(label="Names")
|
86 |
+
inp1 = gr.Label(label="Input First")
|
87 |
+
with gr.Row():
|
88 |
+
res = gr.HTML(label="Result")
|
89 |
+
|
90 |
+
show.click(fn=fetch_all_data, inputs=None, outputs=[user, countr, sdg, res, indi, name, inp1])
|
91 |
+
calculate = gr.Button("Calculate")
|
92 |
+
|
93 |
+
calculate.click(fn=calculate_indicator, inputs=[user, countr, sdg], outputs=res)
|
94 |
+
|
95 |
+
with app:
|
96 |
+
gr.Markdown("""
|
97 |
+
# SRL App
|
98 |
+
""")
|
99 |
+
tab1 = gr.Tab("Sign In")
|
100 |
+
tab2 = gr.Tab("Sign Up")
|
101 |
+
tab3 = gr.Tab("Data Collect")
|
102 |
+
tab4 = gr.Tab("Data Processing")
|
103 |
+
tab5 = gr.Tab("SRL Dash")
|
104 |
+
tab6 = gr.Tab("AI Chat")
|
105 |
+
|
106 |
+
with tab1:
|
107 |
+
iface.render()
|
108 |
+
|
109 |
+
with tab2:
|
110 |
+
iface2.render()
|
111 |
+
|
112 |
+
with tab3:
|
113 |
+
if ifa.visible:
|
114 |
+
ifa.render()
|
115 |
+
|
116 |
+
with tab4:
|
117 |
+
calo.render()
|
118 |
+
|
119 |
+
with tab5:
|
120 |
+
iplot.render()
|
121 |
+
|
122 |
+
with tab6:
|
123 |
+
demo.render()
|
124 |
+
|
125 |
+
app.launch(server_name="0.0.0.0", share=True)
|
126 |
+
|
127 |
+
|
botm.png
ADDED
![]() |
chat2.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from huggingface_hub import InferenceClient
|
2 |
+
import gradio as gr
|
3 |
+
import os
|
4 |
+
cwd = os.getcwd()
|
5 |
+
|
6 |
+
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
7 |
+
|
8 |
+
def format_prompt(message, history):
|
9 |
+
prompt = "<s>"
|
10 |
+
for user_prompt, bot_response in history:
|
11 |
+
prompt += f"[INST] {user_prompt} [/INST]"
|
12 |
+
prompt += f" {bot_response}</s> "
|
13 |
+
prompt += f"[INST] {message} [/INST]"
|
14 |
+
return prompt
|
15 |
+
|
16 |
+
def generate(
|
17 |
+
prompt, history, temperature=0.2, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0,
|
18 |
+
):
|
19 |
+
temperature = float(temperature)
|
20 |
+
if temperature < 1e-2:
|
21 |
+
temperature = 1e-2
|
22 |
+
top_p = float(top_p)
|
23 |
+
|
24 |
+
generate_kwargs = dict(
|
25 |
+
temperature=temperature,
|
26 |
+
max_new_tokens=max_new_tokens,
|
27 |
+
top_p=top_p,
|
28 |
+
repetition_penalty=repetition_penalty,
|
29 |
+
do_sample=True,
|
30 |
+
seed=42,
|
31 |
+
)
|
32 |
+
|
33 |
+
formatted_prompt = format_prompt(prompt, history)
|
34 |
+
|
35 |
+
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
36 |
+
output = ""
|
37 |
+
|
38 |
+
for response in stream:
|
39 |
+
output += response.token.text
|
40 |
+
yield output
|
41 |
+
return output
|
42 |
+
|
43 |
+
botm = os.path.join(cwd, 'botm.png')
|
44 |
+
us = os.path.join(cwd, 'user.png')
|
45 |
+
mychatbot = gr.Chatbot(
|
46 |
+
avatar_images=[us, botm], bubble_full_width=False, show_label=False, show_copy_button=True, likeable=True,)
|
47 |
+
|
48 |
+
demo = gr.ChatInterface(fn=generate,
|
49 |
+
chatbot=mychatbot,
|
50 |
+
title="Discuss with SRL AI Assistant",
|
51 |
+
retry_btn=None,
|
52 |
+
undo_btn=None
|
53 |
+
)
|
54 |
+
|
55 |
+
#demo.queue().launch(show_api=False)
|
data_storage.db
ADDED
Binary file (53.2 kB). View file
|
|
deep.py
ADDED
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
import os
|
4 |
+
import sqlite3
|
5 |
+
from filter import filter_data, sdg_column_mapping
|
6 |
+
from tar import sdg_indicators_mapping, sdg_input_mapping ,sdg_formulas_mapping, sdg_progress_mapping
|
7 |
+
from tqdm import tqdm
|
8 |
+
import time
|
9 |
+
import uuid
|
10 |
+
from datetime import datetime
|
11 |
+
# Load your dataset
|
12 |
+
cwd = os.getcwd()
|
13 |
+
csv_file_path = os.path.join(cwd,'Sustainable_Development_Report_2023_(with_indicators)__-2086263501583264136.csv')
|
14 |
+
data = pd.read_csv(csv_file_path)
|
15 |
+
# Function to create a SQLite database and table if it doesn't exist
|
16 |
+
def sign_in(username, password):
|
17 |
+
try:
|
18 |
+
conn = sqlite3.connect('data_storage.db')
|
19 |
+
c = conn.cursor()
|
20 |
+
|
21 |
+
# Check if the user_sessions table exists
|
22 |
+
c.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='user_sessions'")
|
23 |
+
if c.fetchone() is None:
|
24 |
+
# If the table doesn't exist, create it
|
25 |
+
c.execute("""
|
26 |
+
CREATE TABLE user_sessions (
|
27 |
+
user_id TEXT PRIMARY KEY,
|
28 |
+
timestamp TEXT
|
29 |
+
)
|
30 |
+
""")
|
31 |
+
|
32 |
+
c.execute("SELECT * FROM user_info WHERE username=? AND password=?", (username, password))
|
33 |
+
user = c.fetchone()
|
34 |
+
conn.close()
|
35 |
+
if user:
|
36 |
+
user_id = str(uuid.uuid4())
|
37 |
+
timestamp = datetime.now()
|
38 |
+
conn = sqlite3.connect('data_storage.db')
|
39 |
+
c = conn.cursor()
|
40 |
+
c.execute("INSERT INTO user_sessions (user_id, timestamp) VALUES (?, ?)", (user_id, timestamp))
|
41 |
+
conn.commit()
|
42 |
+
conn.close()
|
43 |
+
return "Welcome, " + username
|
44 |
+
else:
|
45 |
+
return "Invalid username or password"
|
46 |
+
except Exception as e:
|
47 |
+
return str(e)
|
48 |
+
|
49 |
+
def sign_up(username, password, email):
|
50 |
+
try:
|
51 |
+
conn = sqlite3.connect('data_storage.db')
|
52 |
+
c = conn.cursor()
|
53 |
+
|
54 |
+
# Check if the user_info table exists
|
55 |
+
c.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='user_info'")
|
56 |
+
if c.fetchone() is None:
|
57 |
+
# If the table doesn't exist, create it
|
58 |
+
c.execute("""
|
59 |
+
CREATE TABLE user_info (
|
60 |
+
username TEXT PRIMARY KEY,
|
61 |
+
password TEXT,
|
62 |
+
email TEXT
|
63 |
+
)
|
64 |
+
""")
|
65 |
+
|
66 |
+
c.execute("INSERT INTO user_info (username, password, email) VALUES (?, ?, ?)", (username, password, email))
|
67 |
+
conn.commit()
|
68 |
+
conn.close()
|
69 |
+
return "Sign up successful"
|
70 |
+
except Exception as e:
|
71 |
+
return str(e)
|
72 |
+
|
73 |
+
|
74 |
+
def save_inputs(indicator, names, inputs,user_id, timestamp):
|
75 |
+
# Connect to the SQLite database
|
76 |
+
conn = sqlite3.connect('data_storage.db')
|
77 |
+
c = conn.cursor()
|
78 |
+
timestamp = time.time()
|
79 |
+
# Create table if it doesn't exist
|
80 |
+
c.execute('''CREATE TABLE IF NOT EXISTS inputs
|
81 |
+
(indicator text, names text, inputs text, user_id, timestamp)''')
|
82 |
+
|
83 |
+
# Insert a row of data
|
84 |
+
c.execute("INSERT INTO inputs VALUES (?, ?, ?, ?,?)", (indicator, str(names), str(inputs), user_id, timestamp))
|
85 |
+
|
86 |
+
# Save (commit) the changes
|
87 |
+
conn.commit()
|
88 |
+
|
89 |
+
# Close the connection
|
90 |
+
conn.close()
|
91 |
+
|
92 |
+
def create_database():
|
93 |
+
conn = sqlite3.connect("data_storage.db")
|
94 |
+
cursor = conn.cursor()
|
95 |
+
cursor.execute("""
|
96 |
+
CREATE TABLE IF NOT EXISTS user_data (
|
97 |
+
user_id TEXT PRIMARY KEY,
|
98 |
+
username TEXT,
|
99 |
+
country_name TEXT,
|
100 |
+
sdg_number INTEGER,
|
101 |
+
result TEXT,
|
102 |
+
indicator TEXT,
|
103 |
+
names TEXT,
|
104 |
+
input_first REAL,
|
105 |
+
input_2nd REAL,
|
106 |
+
input_3rd REAL,
|
107 |
+
input_4th REAL,
|
108 |
+
timestamp REAL
|
109 |
+
)
|
110 |
+
""")
|
111 |
+
conn.commit()
|
112 |
+
conn.close()
|
113 |
+
|
114 |
+
|
115 |
+
def filter_and_store_data(username, country_name, sdg_number, result, indicator, names, input_first, input_2nd, input_3rd, input_4th, user_id, timestamp):
|
116 |
+
try:
|
117 |
+
# Convert the selected SDG number to an integer
|
118 |
+
sdg_number = int(sdg_number)
|
119 |
+
|
120 |
+
# Get the list of columns based on the selected SDG number
|
121 |
+
selected_columns = ['Name'] + sdg_column_mapping.get(sdg_number, [])
|
122 |
+
|
123 |
+
# Filter data based on country and selected columns
|
124 |
+
selected_data = data[(data['Name'] == country_name)][selected_columns]
|
125 |
+
|
126 |
+
# Convert the selected data to an HTML table with more rows
|
127 |
+
html_table = selected_data.to_html(index=False)
|
128 |
+
|
129 |
+
# Wrap the HTML table in a div with a fixed height and scrollable overflow
|
130 |
+
scrollable_html_table = f'<div style="height: 300px; overflow-y: scroll;">{html_table}</div>'
|
131 |
+
|
132 |
+
# Get the current timestamp
|
133 |
+
timestamp = time.time()
|
134 |
+
timestamp = datetime.now()
|
135 |
+
# Store the data in the SQLite database
|
136 |
+
# Store the data in the SQLite database
|
137 |
+
conn = sqlite3.connect("data_storage.db")
|
138 |
+
cursor = conn.cursor()
|
139 |
+
cursor.execute("INSERT INTO user_data (username, country_name, sdg_number, result, indicator, names, input_first, input_2nd, input_3rd, input_4th, user_id, timestamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
140 |
+
(username, country_name, sdg_number, str(scrollable_html_table), str(indicator), str(names), input_first, input_2nd, input_3rd, input_4th, user_id, timestamp))
|
141 |
+
conn.commit()
|
142 |
+
conn.close()
|
143 |
+
|
144 |
+
return scrollable_html_table
|
145 |
+
except ValueError:
|
146 |
+
return "Please select a valid SDG number.", []
|
147 |
+
except Exception as e:
|
148 |
+
return f"An error occurred: {e}", []
|
149 |
+
|
150 |
+
|
151 |
+
|
152 |
+
def gradio_app(username, country_name, sdg_number, result, indicator, names, input_first, input_2nd, input_3rd, input_4th, user_id, timestamp):
|
153 |
+
# Call the filter_and_store_data function
|
154 |
+
return filter_and_store_data(username, country_name, sdg_number, result, indicator, names, input_first, input_2nd, input_3rd, input_4th, user_id, timestamp)
|
155 |
+
|
156 |
+
def gradios(username, country_name, sdg_number, indicator, names, input_first, input_2nd, input_3rd, input_4th):
|
157 |
+
# Get the formula for the selected indicator
|
158 |
+
formula = sdg_formulas_mapping[indicator]
|
159 |
+
|
160 |
+
# Calculate the result using the formula
|
161 |
+
result = formula(input_first, input_2nd, input_3rd, input_4th)
|
162 |
+
|
163 |
+
# Store the result in the database
|
164 |
+
conn = sqlite3.connect("data_storage.db")
|
165 |
+
cursor = conn.cursor()
|
166 |
+
cursor.execute("""
|
167 |
+
INSERT INTO user_data (username, country_name, sdg_number, result, indicator, names, input_first, input_2nd, input_3rd, input_4th, timestamp)
|
168 |
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
169 |
+
""", (username, country_name, sdg_number, result, indicator, names, input_first, input_2nd, input_3rd, input_4th))
|
170 |
+
conn.commit()
|
171 |
+
conn.close()
|
172 |
+
|
173 |
+
return f"Result: {result}"
|
174 |
+
|
175 |
+
def user_latest_data():
|
176 |
+
conn = sqlite3.connect("data_storage.db")
|
177 |
+
df = pd.read_sql_query("SELECT * FROM user_data ORDER BY username DESC LIMIT 1", conn)
|
178 |
+
conn.close()
|
179 |
+
|
180 |
+
# Convert numeric values to strings
|
181 |
+
return str(df['username'].values[0])
|
182 |
+
|
183 |
+
|
184 |
+
def user_late_data():
|
185 |
+
conn = sqlite3.connect("data_storage.db")
|
186 |
+
df = pd.read_sql_query("SELECT * FROM user_data ORDER BY username DESC LIMIT 1", conn)
|
187 |
+
conn.close()
|
188 |
+
|
189 |
+
# Check if the DataFrame is not empty and contains the 'username' column
|
190 |
+
if not df.empty and 'username' in df.columns and not df['username'].empty:
|
191 |
+
return str(df['username'].values[0])
|
192 |
+
else:
|
193 |
+
return "No username available"
|
194 |
+
|
195 |
+
def get_nam(indicator):
|
196 |
+
if indicator in sdg_input_mapping:
|
197 |
+
names = [item['name'] for item in sdg_input_mapping[indicator]]
|
198 |
+
return names
|
199 |
+
|
200 |
+
def update_nam_dropdown(indicator):
|
201 |
+
return get_nam(indicator)
|
202 |
+
|
203 |
+
def add_indicator(sdg_number):
|
204 |
+
max_inputs = 5
|
205 |
+
def variable_output2(k):
|
206 |
+
k = int(k)
|
207 |
+
return [gr.Number(visible=True)]*k + [gr.Number(visible=False)]*(max_inputs-k)
|
208 |
+
with gr.Row(variant='panel') as row:
|
209 |
+
indicator_dropdown2 = gr.Dropdown(choices=list(sdg_input_mapping.keys()), interactive=True, type="value", label="Please choose an Indicator")
|
210 |
+
names_dropdown = gr.Dropdown(choices=[update_nam_dropdown(indicator_dropdown2.choices[0])], allow_custom_value=True,multiselect=True, interactive=True, type="value", label="The indicators Inputs needed respectively")
|
211 |
+
indicator_dropdown2.change(fn=update_nam_dropdown, inputs=indicator_dropdown2, outputs=names_dropdown)
|
212 |
+
with gr.Column(variant='panel'):
|
213 |
+
u = gr.Slider(1, max_inputs, value=max_inputs, step=1, label="How many inputs to fill:")
|
214 |
+
textboxes = []
|
215 |
+
for i in range(max_inputs):
|
216 |
+
t = gr.Number(label=f"Please fill with the input number {i}", interactive=True)
|
217 |
+
textboxes.append(t)
|
218 |
+
|
219 |
+
u.change(variable_output2, u, textboxes)
|
220 |
+
|
221 |
+
save_button = gr.Button("Save")
|
222 |
+
|
223 |
+
#save_button.click(save_inputs, inputs=[indicator_dropdown2, names_dropdown, t], outputs=[])
|
224 |
+
def save_inputs_wrapper(indicator, names, *textboxes):
|
225 |
+
return save_inputs(indicator, names, [str(t) if isinstance(t, float) else str(t.value) for t in textboxes])
|
226 |
+
save_button.click(save_inputs_wrapper, inputs=[indicator_dropdown2, names_dropdown, *textboxes], outputs=[])
|
227 |
+
return row
|
228 |
+
|
229 |
+
max_indicators = 15
|
230 |
+
|
231 |
+
def variable_outputs(k):
|
232 |
+
k = int(k)
|
233 |
+
num_rows = sdg_progress_mapping.get(k, 0)
|
234 |
+
return [gr.Textbox(visible=True)]*num_rows + [gr.Textbox(visible=False)]*(max_indicators-num_rows)
|
235 |
+
|
236 |
+
def get_new_ind(sdg_number):
|
237 |
+
if sdg_number in sdg_indicators_mapping:
|
238 |
+
ind = sdg_indicators_mapping.get(sdg_number, [])
|
239 |
+
return list(ind)
|
240 |
+
|
241 |
+
def update_indicator_dropdown(sdg_number):
|
242 |
+
return get_new_ind(sdg_number)
|
243 |
+
|
244 |
+
def fetch_all_data():
|
245 |
+
conn = sqlite3.connect("data_storage.db")
|
246 |
+
|
247 |
+
# Fetch user data
|
248 |
+
user_df = pd.read_sql_query("SELECT * FROM user_info", conn)
|
249 |
+
latest_user_row = user_df.iloc[[-1]]
|
250 |
+
user_data = str(latest_user_row['username'].values[0])
|
251 |
+
|
252 |
+
# Fetch user data
|
253 |
+
user_data_df = pd.read_sql_query("SELECT * FROM user_data", conn)
|
254 |
+
latest_user_data_row = user_data_df.iloc[[-1]]
|
255 |
+
user_data_values = (
|
256 |
+
str(latest_user_data_row['country_name'].values[0]),
|
257 |
+
str(latest_user_data_row['sdg_number'].values[0]),
|
258 |
+
str(latest_user_data_row['result'].values[0])
|
259 |
+
)
|
260 |
+
|
261 |
+
# Fetch input data
|
262 |
+
input_df = pd.read_sql_query("SELECT * FROM inputs", conn)
|
263 |
+
latest_input_row = input_df.iloc[[-1]]
|
264 |
+
input_data = (
|
265 |
+
str(latest_input_row['indicator'].values[0]),
|
266 |
+
str(latest_input_row['names'].values[0]),
|
267 |
+
str(latest_input_row['inputs'].values[0])
|
268 |
+
)
|
269 |
+
|
270 |
+
conn.close()
|
271 |
+
|
272 |
+
return [user_data] + list(user_data_values) + list(input_data)
|
273 |
+
|
274 |
+
|
275 |
+
|
276 |
+
def calculate_indicator(user_id, timestamp):
|
277 |
+
try:
|
278 |
+
conn = sqlite3.connect("data_storage.db")
|
279 |
+
|
280 |
+
# Fetch user data based on user_id and timestamp
|
281 |
+
user_data_df = pd.read_sql_query("SELECT * FROM user_data WHERE user_id=? AND timestamp=?", conn, params=(user_id, timestamp))
|
282 |
+
|
283 |
+
if user_data_df.empty:
|
284 |
+
return "No data found for the specified user_id and timestamp"
|
285 |
+
|
286 |
+
# Extract relevant information
|
287 |
+
indicator = user_data_df['indicator'].values[0]
|
288 |
+
names = user_data_df['names'].values[0]
|
289 |
+
input_first = user_data_df['input_first'].values[0]
|
290 |
+
|
291 |
+
# Perform the calculation
|
292 |
+
if indicator in sdg_formulas_mapping:
|
293 |
+
formula = sdg_formulas_mapping[indicator]
|
294 |
+
result = formula(input_first)
|
295 |
+
return f"Result for {indicator}: {result}"
|
296 |
+
else:
|
297 |
+
return f"Indicator {indicator} not found in the dictionary"
|
298 |
+
|
299 |
+
except Exception as e:
|
300 |
+
return f"An error occurred: {e}"
|
docker-compose.yml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: '3'
|
2 |
+
|
3 |
+
services:
|
4 |
+
app:
|
5 |
+
build: .
|
6 |
+
ports:
|
7 |
+
- "55006:55006"
|
filter.py
ADDED
@@ -0,0 +1,317 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
sdg_column_mapping = {
|
5 |
+
0:[
|
6 |
+
'Goal_Rating', 'Goal_Trend', 'Value_sdg_earlyedu', 'Year_sdg_earlyedu', 'impute_sdg_earlyedu',
|
7 |
+
'Score_sdg_earlyedu', 'Rating_sdg_earlyedu', 'Trend_sdg_earlyedu', 'Value_sdg_primary',
|
8 |
+
'Year_sdg_primary', 'Score_sdg_primary', 'Rating_sdg_primary', 'Trend_sdg_primary',
|
9 |
+
'Value_sdg_second', 'Year_sdg_second', 'impute_sdg_second', 'Score_sdg_second', 'Rating_sdg_second',
|
10 |
+
'Trend_sdg_second', 'Value_sdg_literacy', 'Year_sdg_literacy', 'Score_sdg_literacy', 'Rating_sdg_literacy',
|
11 |
+
'Trend_sdg_literacy', 'Value_sdg_tertiary', 'Year_sdg_tertiary', 'Score_sdg_tertiary', 'Rating_sdg_tertiary',
|
12 |
+
'Trend_sdg_tertiary', 'Value_sdg_pisa', 'Year_sdg_pisa', 'Rating_sdg_pisa', 'Trend_sdg_pisa',
|
13 |
+
'Value_sdg_socioec', 'Year_sdg_socioec', 'Rating_sdg_socioec', 'Trend_sdg_socioec', 'Value_sdg_science',
|
14 |
+
'Year_sdg_science', 'Rating_sdg_science', 'Trend_sdg_science',],
|
15 |
+
3:[
|
16 |
+
'Goal_3_Rating', 'Goal_3_Trend', 'Value_sdg3_matmort', 'Year_sdg3_matmort',
|
17 |
+
'Score_sdg3_matmort', 'Rating_sdg3_matmort', 'Trend_sdg3_matmort', 'Value_sdg3_neonat',
|
18 |
+
'Year_sdg3_neonat', 'Score_sdg3_neonat', 'Rating_sdg3_neonat', 'Trend_sdg3_neonat', 'Value_sdg3_u5mort',
|
19 |
+
'Year_sdg3_u5mort', 'Score_sdg3_u5mort', 'Rating_sdg3_u5mort', 'Trend_sdg3_u5mort', 'Value_sdg3_tb',
|
20 |
+
'Year_sdg3_tb', 'Score_sdg3_tb', 'Rating_sdg3_tb', 'Trend_sdg3_tb', 'Value_sdg3_hiv', 'Year_sdg3_hiv',
|
21 |
+
'Score_sdg3_hiv', 'Rating_sdg3_hiv', 'Trend_sdg3_hiv', 'Value_sdg3_ncds', 'Year_sdg3_ncds', 'Score_sdg3_ncds',
|
22 |
+
'Rating_sdg3_ncds', 'Trend_sdg3_ncds', 'Value_sdg3_pollmort', 'Year_sdg3_pollmort', 'Score_sdg3_pollmort',
|
23 |
+
'Rating_sdg3_pollmort', 'Value_sdg3_traffic', 'Year_sdg3_traffic', 'Score_sdg3_traffic', 'Rating_sdg3_traffic',
|
24 |
+
'Trend_sdg3_traffic', 'Value_sdg3_lifee', 'Year_sdg3_lifee', 'Score_sdg3_lifee', 'Rating_sdg3_lifee',
|
25 |
+
'Trend_sdg3_lifee', 'Value_sdg3_fertility', 'Year_sdg3_fertility', 'Score_sdg3_fertility', 'Rating_sdg3_fertility',
|
26 |
+
'Trend_sdg3_fertility', 'Value_sdg3_births', 'Year_sdg3_births', 'Score_sdg3_births', 'Rating_sdg3_births',
|
27 |
+
'Trend_sdg3_births', 'Value_sdg3_vac', 'Year_sdg3_vac', 'Score_sdg3_vac', 'Rating_sdg3_vac', 'Trend_sdg3_vac',
|
28 |
+
'Value_sdg3_uhc', 'Year_sdg3_uhc', 'Score_sdg3_uhc', 'Rating_sdg3_uhc', 'Trend_sdg3_uhc', 'Value_sdg3_swb',
|
29 |
+
'Year_sdg3_swb', 'Score_sdg3_swb', 'Rating_sdg3_swb', 'Trend_sdg3_swb', 'Value_sdg3_region', 'Year_sdg3_region',
|
30 |
+
'Rating_sdg3_region', 'Trend_sdg3_region', 'Value_sdg3_incomeg', 'Year_sdg3_incomeg', 'Rating_sdg3_incomeg',
|
31 |
+
'Trend_sdg3_incomeg', 'Value_sdg3_smoke', 'Year_sdg3_smoke', 'Rating_sdg3_smoke', 'Trend_sdg3_smoke',
|
32 |
+
],
|
33 |
+
4: [
|
34 |
+
'Goal_4_Rating', 'Goal_4_Trend', 'Value_sdg4_earlyedu', 'Year_sdg4_earlyedu',
|
35 |
+
'Score_sdg4_earlyedu', 'Rating_sdg4_earlyedu', 'Value_sdg4_primary',
|
36 |
+
'Year_sdg4_primary', 'Score_sdg4_primary', 'Rating_sdg4_primary',
|
37 |
+
'Trend_sdg4_primary', 'Value_sdg4_second', 'Year_sdg4_second',
|
38 |
+
'impute_sdg4_second', 'Score_sdg4_second', 'Rating_sdg4_second',
|
39 |
+
'Trend_sdg4_second', 'Value_sdg4_literacy', 'Year_sdg4_literacy',
|
40 |
+
'Score_sdg4_literacy', 'Rating_sdg4_literacy', 'Trend_sdg4_literacy',
|
41 |
+
'Value_sdg4_tertiary', 'Year_sdg4_tertiary', 'Rating_sdg4_tertiary',
|
42 |
+
'Trend_sdg4_tertiary', 'Value_sdg4_pisa', 'Year_sdg4_pisa',
|
43 |
+
'Rating_sdg4_pisa', 'Trend_sdg4_pisa', 'Value_sdg4_socioec',
|
44 |
+
'Year_sdg4_socioec', 'Rating_sdg4_socioec', 'Trend_sdg4_socioec',
|
45 |
+
'Value_sdg4_science', 'Year_sdg4_science', 'Rating_sdg4_science',
|
46 |
+
],
|
47 |
+
5:[
|
48 |
+
'Goal_5_Rating', 'Goal_5_Trend', 'Value_sdg5_rratio', 'Year_sdg5_rratio',
|
49 |
+
'Score_sdg5_rratio', 'Rating_sdg5_rratio', 'Trend_sdg5_rratio', 'Value_sdg5_vawage',
|
50 |
+
'Year_sdg5_vawage', 'Score_sdg5_vawage', 'Rating_sdg5_vawage', 'Trend_sdg5_vawage', 'Value_sdg5_lfpart',
|
51 |
+
'Year_sdg5_lfpart', 'Score_sdg5_lfpart', 'Rating_sdg5_lfpart', 'Trend_sdg5_lfpart', 'Value_sdg5_parl',
|
52 |
+
'Year_sdg5_parl', 'Score_sdg5_parl', 'Rating_sdg5_parl', 'Trend_sdg5_parl', 'Value_sdg5_fgm', 'Year_sdg5_fgm',
|
53 |
+
'Score_sdg5_fgm', 'Rating_sdg5_fgm', 'Trend_sdg5_fgm', 'Value_sdg5_cmarry', 'Year_sdg5_cmarry', 'Score_sdg5_cmarry',
|
54 |
+
'Rating_sdg5_cmarry', 'Trend_sdg5_cmarry', 'Value_sdg5_vabirth', 'Year_sdg5_vabirth', 'Score_sdg5_vabirth',
|
55 |
+
'Rating_sdg5_vabirth', 'Trend_sdg5_vabirth',
|
56 |
+
],
|
57 |
+
6:[
|
58 |
+
'Goal_6_Rating', 'Goal_6_Trend', 'Value_sdg6_safewater', 'Year_sdg6_safewater',
|
59 |
+
'Score_sdg6_safewater', 'Rating_sdg6_safewater', 'Trend_sdg6_safewater', 'Value_sdg6_sanitation',
|
60 |
+
'Year_sdg6_sanitation', 'Score_sdg6_sanitation', 'Rating_sdg6_sanitation', 'Trend_sdg6_sanitation',
|
61 |
+
'Value_sdg6_freshwater', 'Year_sdg6_freshwater', 'Score_sdg6_freshwater', 'Rating_sdg6_freshwater',
|
62 |
+
'Trend_sdg6_freshwater', 'Value_sdg6_ecosystems', 'Year_sdg6_ecosystems', 'Score_sdg6_ecosystems',
|
63 |
+
'Rating_sdg6_ecosystems', 'Trend_sdg6_ecosystems', 'Value_sdg6_wateruse', 'Year_sdg6_wateruse',
|
64 |
+
'Score_sdg6_wateruse', 'Rating_sdg6_wateruse', 'Trend_sdg6_wateruse', 'Value_sdg6_waterstress',
|
65 |
+
'Year_sdg6_waterstress', 'Score_sdg6_waterstress', 'Rating_sdg6_waterstress', 'Trend_sdg6_waterstress',
|
66 |
+
'Value_sdg6_quality', 'Year_sdg6_quality', 'Score_sdg6_quality', 'Rating_sdg6_quality', 'Trend_sdg6_quality',
|
67 |
+
'Value_sdg6_wastewater', 'Year_sdg6_wastewater', 'Score_sdg6_wastewater', 'Rating_sdg6_wastewater',
|
68 |
+
'Trend_sdg6_wastewater', 'Value_sdg6_river', 'Year_sdg6_river', 'Score_sdg6_river', 'Rating_sdg6_river',
|
69 |
+
'Trend_sdg6_river', 'Value_sdg6_fisheries', 'Year_sdg6_fisheries', 'Score_sdg6_fisheries',
|
70 |
+
'Rating_sdg6_fisheries', 'Trend_sdg6_fisheries',
|
71 |
+
],
|
72 |
+
7:[
|
73 |
+
'Goal_7_Rating', 'Goal_7_Trend', 'Value_sdg7_access', 'Year_sdg7_access',
|
74 |
+
'Score_sdg7_access', 'Rating_sdg7_access', 'Trend_sdg7_access', 'Value_sdg7_electrify',
|
75 |
+
'Year_sdg7_electrify', 'Score_sdg7_electrify', 'Rating_sdg7_electrify', 'Trend_sdg7_electrify',
|
76 |
+
'Value_sdg7_renewcon', 'Year_sdg7_renewcon', 'Score_sdg7_renewcon', 'Rating_sdg7_renewcon',
|
77 |
+
'Trend_sdg7_renewcon', 'Value_sdg7_afford', 'Year_sdg7_afford', 'Score_sdg7_afford',
|
78 |
+
'Rating_sdg7_afford', 'Trend_sdg7_afford', 'Value_sdg7_cleancook', 'Year_sdg7_cleancook',
|
79 |
+
'Score_sdg7_cleancook', 'Rating_sdg7_cleancook', 'Trend_sdg7_cleancook', 'Value_sdg7_nonrenewcon',
|
80 |
+
'Year_sdg7_nonrenewcon', 'Score_sdg7_nonrenewcon', 'Rating_sdg7_nonrenewcon',
|
81 |
+
'Trend_sdg7_nonrenewcon', 'Value_sdg7_biofuel', 'Year_sdg7_biofuel', 'Score_sdg7_biofuel',
|
82 |
+
'Rating_sdg7_biofuel', 'Trend_sdg7_biofuel',
|
83 |
+
],
|
84 |
+
8:[
|
85 |
+
'Goal_8_Rating', 'Goal_8_Trend', 'Value_sdg8_adjgrowth', 'Year_sdg8_adjgrowth',
|
86 |
+
'Score_sdg8_adjgrowth', 'Rating_sdg8_adjgrowth', 'Value_sdg8_slavery', 'Year_sdg8_slavery',
|
87 |
+
'impute_sdg8_slavery', 'Score_sdg8_slavery', 'Rating_sdg8_slavery', 'Value_sdg8_accounts',
|
88 |
+
'Year_sdg8_accounts', 'Score_sdg8_accounts', 'Rating_sdg8_accounts', 'Trend_sdg8_accounts',
|
89 |
+
'Value_sdg8_unemp', 'Year_sdg8_unemp', 'Score_sdg8_unemp', 'Rating_sdg8_unemp',
|
90 |
+
'Trend_sdg8_unemp',
|
91 |
+
],
|
92 |
+
9:[
|
93 |
+
'Goal_9_Rating', 'Goal_9_Trend', 'Value_sdg9_roads', 'Year_sdg9_roads',
|
94 |
+
'Score_sdg9_roads', 'Rating_sdg9_roads', 'Value_sdg9_intuse', 'Year_sdg9_intuse',
|
95 |
+
'Score_sdg9_intuse', 'Rating_sdg9_intuse', 'Trend_sdg9_intuse', 'Value_sdg9_mobuse',
|
96 |
+
'Year_sdg9_mobuse', 'Score_sdg9_mobuse', 'Rating_sdg9_mobuse', 'Trend_sdg9_mobuse',
|
97 |
+
'Value_sdg9_lpi', 'Year_sdg9_lpi', 'Score_sdg9_lpi', 'Rating_sdg9_lpi', 'Trend_sdg9_lpi',
|
98 |
+
'Value_sdg9_uni', 'Year_sdg9_uni', 'impute_sdg9_uni', 'Score_sdg9_uni', 'Rating_sdg9_uni',
|
99 |
+
'Value_sdg9_articles', 'Year_sdg9_articles', 'Score_sdg9_articles', 'Rating_sdg9_articles',
|
100 |
+
'Trend_sdg9_articles', 'Value_sdg9_rdex', 'Year_sdg9_rdex', 'impute_sdg9_rdex', 'Score_sdg9_rdex',
|
101 |
+
'Rating_sdg9_rdex', 'Trend_sdg9_rdex', 'Value_sdg9_rdres', 'Year_sdg9_rdres',
|
102 |
+
'Rating_sdg9_rdres', 'Trend_sdg9_rdres', 'Value_sdg9_patents', 'Year_sdg9_patents',
|
103 |
+
'Rating_sdg9_patents', 'Trend_sdg9_patents', 'Value_sdg9_netacc', 'Year_sdg9_netacc',
|
104 |
+
'Rating_sdg9_netacc', 'Trend_sdg9_netacc', 'Value_sdg9_womensci', 'Year_sdg9_womensci',
|
105 |
+
'Rating_sdg9_womensci', 'Trend_sdg9_womensci',
|
106 |
+
],
|
107 |
+
10:[
|
108 |
+
'Goal_10_Rating', 'Goal_10_Trend', 'Value_sdg10_gini', 'Year_sdg10_gini',
|
109 |
+
'Score_sdg10_gini', 'Rating_sdg10_gini', 'Trend_sdg10_gini', 'Value_sdg10_palma',
|
110 |
+
'Year_sdg10_palma', 'Score_sdg10_palma', 'Rating_sdg10_palma', 'Trend_sdg10_palma',
|
111 |
+
'Value_sdg10_elder', 'Year_sdg10_elder', 'Rating_sdg10_elder', 'Trend_sdg10_elder',
|
112 |
+
],
|
113 |
+
11:[
|
114 |
+
'Goal_11_Rating', 'Goal_11_Trend', 'Value_sdg11_slums', 'Year_sdg11_slums',
|
115 |
+
'impute_sdg11_slums', 'Score_sdg11_slums', 'Rating_sdg11_slums', 'Trend_sdg11_slums',
|
116 |
+
'Value_sdg11_pm25', 'Year_sdg11_pm25', 'Score_sdg11_pm25', 'Rating_sdg11_pm25',
|
117 |
+
'Trend_sdg11_pm25', 'Value_sdg11_pipedwat', 'Year_sdg11_pipedwat',
|
118 |
+
'Score_sdg11_pipedwat', 'Rating_sdg11_pipedwat', 'Trend_sdg11_pipedwat',
|
119 |
+
'Value_sdg11_transport', 'Year_sdg11_transport', 'Score_sdg11_transport',
|
120 |
+
'Rating_sdg11_transport', 'Trend_sdg11_transport', 'Value_sdg11_rentover',
|
121 |
+
'Year_sdg11_rentover', 'Rating_sdg11_rentover', 'Trend_sdg11_rentover',
|
122 |
+
'Value_sdg11_walkable', 'Year_sdg11_walkable', 'Rating_sdg11_walkable',
|
123 |
+
],
|
124 |
+
12:[
|
125 |
+
'Goal_12_Rating', 'Goal_12_Trend', 'Value_sdg12_waste', 'Year_sdg12_waste',
|
126 |
+
'impute_sdg12_waste', 'Score_sdg12_waste', 'Rating_sdg12_waste', 'Trend_sdg12_waste',
|
127 |
+
'Value_sdg12_recycling', 'Year_sdg12_recycling', 'impute_sdg12_recycling',
|
128 |
+
'Score_sdg12_recycling', 'Rating_sdg12_recycling', 'Trend_sdg12_recycling',
|
129 |
+
'Value_sdg12_solidwaste', 'Year_sdg12_solidwaste', 'impute_sdg12_solidwaste',
|
130 |
+
'Score_sdg12_solidwaste', 'Rating_sdg12_solidwaste', 'Trend_sdg12_solidwaste',
|
131 |
+
],
|
132 |
+
13:[
|
133 |
+
'Goal_13_Rating', 'Goal_13_Trend', 'Value_sdg13_emissions', 'Year_sdg13_emissions',
|
134 |
+
'impute_sdg13_emissions', 'Score_sdg13_emissions', 'Rating_sdg13_emissions',
|
135 |
+
'Trend_sdg13_emissions', 'Value_sdg13_forests', 'Year_sdg13_forests',
|
136 |
+
'impute_sdg13_forests', 'Score_sdg13_forests', 'Rating_sdg13_forests',
|
137 |
+
'Trend_sdg13_forests',
|
138 |
+
],
|
139 |
+
14:[
|
140 |
+
'Goal_14_Rating', 'Goal_14_Trend', 'Value_sdg14_overfishing', 'Year_sdg14_overfishing',
|
141 |
+
'impute_sdg14_overfishing', 'Score_sdg14_overfishing', 'Rating_sdg14_overfishing',
|
142 |
+
'Trend_sdg14_overfishing', 'Value_sdg14_mpa', 'Year_sdg14_mpa', 'impute_sdg14_mpa',
|
143 |
+
'Score_sdg14_mpa', 'Rating_sdg14_mpa', 'Trend_sdg14_mpa',
|
144 |
+
],
|
145 |
+
17:[
|
146 |
+
'Goal_17_Rating', 'Goal_17_Trend', 'Value_sdg17_govex', 'Year_sdg17_govex',
|
147 |
+
'Score_sdg17_govex', 'Rating_sdg17_govex', 'Trend_sdg17_govex', 'Value_sdg17_oda',
|
148 |
+
'Year_sdg17_oda', 'Score_sdg17_oda', 'Rating_sdg17_oda', 'Trend_sdg17_oda',
|
149 |
+
'Value_sdg17_fp', 'Year_sdg17_fp', 'impute_sdg17_fp', 'Score_sdg17_fp',
|
150 |
+
'Rating_sdg17_fp', 'Trend_sdg17_fp',
|
151 |
+
]
|
152 |
+
}
|
153 |
+
|
154 |
+
def filter_data(country_name, sdg_number):
|
155 |
+
# Load your dataset
|
156 |
+
data = pd.read_csv(r'C:\Users\Samer\OneDrive\DS\SDG\new\Sustainable_Development_Report_2023_(with_indicators)__-2086263501583264136.csv')
|
157 |
+
|
158 |
+
# Create a mapping of SDG numbers to their corresponding columns
|
159 |
+
sdg_column_mapping = {
|
160 |
+
0:[
|
161 |
+
'Goal_Rating', 'Goal_Trend', 'Value_sdg_earlyedu', 'Year_sdg_earlyedu', 'impute_sdg_earlyedu',
|
162 |
+
'Score_sdg_earlyedu', 'Rating_sdg_earlyedu', 'Trend_sdg_earlyedu', 'Value_sdg_primary',
|
163 |
+
'Year_sdg_primary', 'Score_sdg_primary', 'Rating_sdg_primary', 'Trend_sdg_primary',
|
164 |
+
'Value_sdg_second', 'Year_sdg_second', 'impute_sdg_second', 'Score_sdg_second', 'Rating_sdg_second',
|
165 |
+
'Trend_sdg_second', 'Value_sdg_literacy', 'Year_sdg_literacy', 'Score_sdg_literacy', 'Rating_sdg_literacy',
|
166 |
+
'Trend_sdg_literacy', 'Value_sdg_tertiary', 'Year_sdg_tertiary', 'Score_sdg_tertiary', 'Rating_sdg_tertiary',
|
167 |
+
'Trend_sdg_tertiary', 'Value_sdg_pisa', 'Year_sdg_pisa', 'Rating_sdg_pisa', 'Trend_sdg_pisa',
|
168 |
+
'Value_sdg_socioec', 'Year_sdg_socioec', 'Rating_sdg_socioec', 'Trend_sdg_socioec', 'Value_sdg_science',
|
169 |
+
'Year_sdg_science', 'Rating_sdg_science', 'Trend_sdg_science',],
|
170 |
+
3:[
|
171 |
+
'Goal_3_Rating', 'Goal_3_Trend', 'Value_sdg3_matmort', 'Year_sdg3_matmort',
|
172 |
+
'Score_sdg3_matmort', 'Rating_sdg3_matmort', 'Trend_sdg3_matmort', 'Value_sdg3_neonat',
|
173 |
+
'Year_sdg3_neonat', 'Score_sdg3_neonat', 'Rating_sdg3_neonat', 'Trend_sdg3_neonat', 'Value_sdg3_u5mort',
|
174 |
+
'Year_sdg3_u5mort', 'Score_sdg3_u5mort', 'Rating_sdg3_u5mort', 'Trend_sdg3_u5mort', 'Value_sdg3_tb',
|
175 |
+
'Year_sdg3_tb', 'Score_sdg3_tb', 'Rating_sdg3_tb', 'Trend_sdg3_tb', 'Value_sdg3_hiv', 'Year_sdg3_hiv',
|
176 |
+
'Score_sdg3_hiv', 'Rating_sdg3_hiv', 'Trend_sdg3_hiv', 'Value_sdg3_ncds', 'Year_sdg3_ncds', 'Score_sdg3_ncds',
|
177 |
+
'Rating_sdg3_ncds', 'Trend_sdg3_ncds', 'Value_sdg3_pollmort', 'Year_sdg3_pollmort', 'Score_sdg3_pollmort',
|
178 |
+
'Rating_sdg3_pollmort', 'Value_sdg3_traffic', 'Year_sdg3_traffic', 'Score_sdg3_traffic', 'Rating_sdg3_traffic',
|
179 |
+
'Trend_sdg3_traffic', 'Value_sdg3_lifee', 'Year_sdg3_lifee', 'Score_sdg3_lifee', 'Rating_sdg3_lifee',
|
180 |
+
'Trend_sdg3_lifee', 'Value_sdg3_fertility', 'Year_sdg3_fertility', 'Score_sdg3_fertility', 'Rating_sdg3_fertility',
|
181 |
+
'Trend_sdg3_fertility', 'Value_sdg3_births', 'Year_sdg3_births', 'Score_sdg3_births', 'Rating_sdg3_births',
|
182 |
+
'Trend_sdg3_births', 'Value_sdg3_vac', 'Year_sdg3_vac', 'Score_sdg3_vac', 'Rating_sdg3_vac', 'Trend_sdg3_vac',
|
183 |
+
'Value_sdg3_uhc', 'Year_sdg3_uhc', 'Score_sdg3_uhc', 'Rating_sdg3_uhc', 'Trend_sdg3_uhc', 'Value_sdg3_swb',
|
184 |
+
'Year_sdg3_swb', 'Score_sdg3_swb', 'Rating_sdg3_swb', 'Trend_sdg3_swb', 'Value_sdg3_region', 'Year_sdg3_region',
|
185 |
+
'Rating_sdg3_region', 'Trend_sdg3_region', 'Value_sdg3_incomeg', 'Year_sdg3_incomeg', 'Rating_sdg3_incomeg',
|
186 |
+
'Trend_sdg3_incomeg', 'Value_sdg3_smoke', 'Year_sdg3_smoke', 'Rating_sdg3_smoke', 'Trend_sdg3_smoke',
|
187 |
+
],
|
188 |
+
4: [
|
189 |
+
'Goal_4_Rating', 'Goal_4_Trend', 'Value_sdg4_earlyedu', 'Year_sdg4_earlyedu',
|
190 |
+
'Score_sdg4_earlyedu', 'Rating_sdg4_earlyedu', 'Value_sdg4_primary',
|
191 |
+
'Year_sdg4_primary', 'Score_sdg4_primary', 'Rating_sdg4_primary',
|
192 |
+
'Trend_sdg4_primary', 'Value_sdg4_second', 'Year_sdg4_second',
|
193 |
+
'impute_sdg4_second', 'Score_sdg4_second', 'Rating_sdg4_second',
|
194 |
+
'Trend_sdg4_second', 'Value_sdg4_literacy', 'Year_sdg4_literacy',
|
195 |
+
'Score_sdg4_literacy', 'Rating_sdg4_literacy', 'Trend_sdg4_literacy',
|
196 |
+
'Value_sdg4_tertiary', 'Year_sdg4_tertiary', 'Rating_sdg4_tertiary',
|
197 |
+
'Trend_sdg4_tertiary', 'Value_sdg4_pisa', 'Year_sdg4_pisa',
|
198 |
+
'Rating_sdg4_pisa', 'Trend_sdg4_pisa', 'Value_sdg4_socioec',
|
199 |
+
'Year_sdg4_socioec', 'Rating_sdg4_socioec', 'Trend_sdg4_socioec',
|
200 |
+
'Value_sdg4_science', 'Year_sdg4_science', 'Rating_sdg4_science',
|
201 |
+
],
|
202 |
+
5:[
|
203 |
+
'Goal_5_Rating', 'Goal_5_Trend', 'Value_sdg5_rratio', 'Year_sdg5_rratio',
|
204 |
+
'Score_sdg5_rratio', 'Rating_sdg5_rratio', 'Trend_sdg5_rratio', 'Value_sdg5_vawage',
|
205 |
+
'Year_sdg5_vawage', 'Score_sdg5_vawage', 'Rating_sdg5_vawage', 'Trend_sdg5_vawage', 'Value_sdg5_lfpart',
|
206 |
+
'Year_sdg5_lfpart', 'Score_sdg5_lfpart', 'Rating_sdg5_lfpart', 'Trend_sdg5_lfpart', 'Value_sdg5_parl',
|
207 |
+
'Year_sdg5_parl', 'Score_sdg5_parl', 'Rating_sdg5_parl', 'Trend_sdg5_parl', 'Value_sdg5_fgm', 'Year_sdg5_fgm',
|
208 |
+
'Score_sdg5_fgm', 'Rating_sdg5_fgm', 'Trend_sdg5_fgm', 'Value_sdg5_cmarry', 'Year_sdg5_cmarry', 'Score_sdg5_cmarry',
|
209 |
+
'Rating_sdg5_cmarry', 'Trend_sdg5_cmarry', 'Value_sdg5_vabirth', 'Year_sdg5_vabirth', 'Score_sdg5_vabirth',
|
210 |
+
'Rating_sdg5_vabirth', 'Trend_sdg5_vabirth',
|
211 |
+
],
|
212 |
+
6:[
|
213 |
+
'Goal_6_Rating', 'Goal_6_Trend', 'Value_sdg6_safewater', 'Year_sdg6_safewater',
|
214 |
+
'Score_sdg6_safewater', 'Rating_sdg6_safewater', 'Trend_sdg6_safewater', 'Value_sdg6_sanitation',
|
215 |
+
'Year_sdg6_sanitation', 'Score_sdg6_sanitation', 'Rating_sdg6_sanitation', 'Trend_sdg6_sanitation',
|
216 |
+
'Value_sdg6_freshwater', 'Year_sdg6_freshwater', 'Score_sdg6_freshwater', 'Rating_sdg6_freshwater',
|
217 |
+
'Trend_sdg6_freshwater', 'Value_sdg6_ecosystems', 'Year_sdg6_ecosystems', 'Score_sdg6_ecosystems',
|
218 |
+
'Rating_sdg6_ecosystems', 'Trend_sdg6_ecosystems', 'Value_sdg6_wateruse', 'Year_sdg6_wateruse',
|
219 |
+
'Score_sdg6_wateruse', 'Rating_sdg6_wateruse', 'Trend_sdg6_wateruse', 'Value_sdg6_waterstress',
|
220 |
+
'Year_sdg6_waterstress', 'Score_sdg6_waterstress', 'Rating_sdg6_waterstress', 'Trend_sdg6_waterstress',
|
221 |
+
'Value_sdg6_quality', 'Year_sdg6_quality', 'Score_sdg6_quality', 'Rating_sdg6_quality', 'Trend_sdg6_quality',
|
222 |
+
'Value_sdg6_wastewater', 'Year_sdg6_wastewater', 'Score_sdg6_wastewater', 'Rating_sdg6_wastewater',
|
223 |
+
'Trend_sdg6_wastewater', 'Value_sdg6_river', 'Year_sdg6_river', 'Score_sdg6_river', 'Rating_sdg6_river',
|
224 |
+
'Trend_sdg6_river', 'Value_sdg6_fisheries', 'Year_sdg6_fisheries', 'Score_sdg6_fisheries',
|
225 |
+
'Rating_sdg6_fisheries', 'Trend_sdg6_fisheries',
|
226 |
+
],
|
227 |
+
7:[
|
228 |
+
'Goal_7_Rating', 'Goal_7_Trend', 'Value_sdg7_access', 'Year_sdg7_access',
|
229 |
+
'Score_sdg7_access', 'Rating_sdg7_access', 'Trend_sdg7_access', 'Value_sdg7_electrify',
|
230 |
+
'Year_sdg7_electrify', 'Score_sdg7_electrify', 'Rating_sdg7_electrify', 'Trend_sdg7_electrify',
|
231 |
+
'Value_sdg7_renewcon', 'Year_sdg7_renewcon', 'Score_sdg7_renewcon', 'Rating_sdg7_renewcon',
|
232 |
+
'Trend_sdg7_renewcon', 'Value_sdg7_afford', 'Year_sdg7_afford', 'Score_sdg7_afford',
|
233 |
+
'Rating_sdg7_afford', 'Trend_sdg7_afford', 'Value_sdg7_cleancook', 'Year_sdg7_cleancook',
|
234 |
+
'Score_sdg7_cleancook', 'Rating_sdg7_cleancook', 'Trend_sdg7_cleancook', 'Value_sdg7_nonrenewcon',
|
235 |
+
'Year_sdg7_nonrenewcon', 'Score_sdg7_nonrenewcon', 'Rating_sdg7_nonrenewcon',
|
236 |
+
'Trend_sdg7_nonrenewcon', 'Value_sdg7_biofuel', 'Year_sdg7_biofuel', 'Score_sdg7_biofuel',
|
237 |
+
'Rating_sdg7_biofuel', 'Trend_sdg7_biofuel',
|
238 |
+
],
|
239 |
+
8:[
|
240 |
+
'Goal_8_Rating', 'Goal_8_Trend', 'Value_sdg8_adjgrowth', 'Year_sdg8_adjgrowth',
|
241 |
+
'Score_sdg8_adjgrowth', 'Rating_sdg8_adjgrowth', 'Value_sdg8_slavery', 'Year_sdg8_slavery',
|
242 |
+
'impute_sdg8_slavery', 'Score_sdg8_slavery', 'Rating_sdg8_slavery', 'Value_sdg8_accounts',
|
243 |
+
'Year_sdg8_accounts', 'Score_sdg8_accounts', 'Rating_sdg8_accounts', 'Trend_sdg8_accounts',
|
244 |
+
'Value_sdg8_unemp', 'Year_sdg8_unemp', 'Score_sdg8_unemp', 'Rating_sdg8_unemp',
|
245 |
+
'Trend_sdg8_unemp',
|
246 |
+
],
|
247 |
+
9:[
|
248 |
+
'Goal_9_Rating', 'Goal_9_Trend', 'Value_sdg9_roads', 'Year_sdg9_roads',
|
249 |
+
'Score_sdg9_roads', 'Rating_sdg9_roads', 'Value_sdg9_intuse', 'Year_sdg9_intuse',
|
250 |
+
'Score_sdg9_intuse', 'Rating_sdg9_intuse', 'Trend_sdg9_intuse', 'Value_sdg9_mobuse',
|
251 |
+
'Year_sdg9_mobuse', 'Score_sdg9_mobuse', 'Rating_sdg9_mobuse', 'Trend_sdg9_mobuse',
|
252 |
+
'Value_sdg9_lpi', 'Year_sdg9_lpi', 'Score_sdg9_lpi', 'Rating_sdg9_lpi', 'Trend_sdg9_lpi',
|
253 |
+
'Value_sdg9_uni', 'Year_sdg9_uni', 'impute_sdg9_uni', 'Score_sdg9_uni', 'Rating_sdg9_uni',
|
254 |
+
'Value_sdg9_articles', 'Year_sdg9_articles', 'Score_sdg9_articles', 'Rating_sdg9_articles',
|
255 |
+
'Trend_sdg9_articles', 'Value_sdg9_rdex', 'Year_sdg9_rdex', 'impute_sdg9_rdex', 'Score_sdg9_rdex',
|
256 |
+
'Rating_sdg9_rdex', 'Trend_sdg9_rdex', 'Value_sdg9_rdres', 'Year_sdg9_rdres',
|
257 |
+
'Rating_sdg9_rdres', 'Trend_sdg9_rdres', 'Value_sdg9_patents', 'Year_sdg9_patents',
|
258 |
+
'Rating_sdg9_patents', 'Trend_sdg9_patents', 'Value_sdg9_netacc', 'Year_sdg9_netacc',
|
259 |
+
'Rating_sdg9_netacc', 'Trend_sdg9_netacc', 'Value_sdg9_womensci', 'Year_sdg9_womensci',
|
260 |
+
'Rating_sdg9_womensci', 'Trend_sdg9_womensci',
|
261 |
+
],
|
262 |
+
10:[
|
263 |
+
'Goal_10_Rating', 'Goal_10_Trend', 'Value_sdg10_gini', 'Year_sdg10_gini',
|
264 |
+
'Score_sdg10_gini', 'Rating_sdg10_gini', 'Trend_sdg10_gini', 'Value_sdg10_palma',
|
265 |
+
'Year_sdg10_palma', 'Score_sdg10_palma', 'Rating_sdg10_palma', 'Trend_sdg10_palma',
|
266 |
+
'Value_sdg10_elder', 'Year_sdg10_elder', 'Rating_sdg10_elder', 'Trend_sdg10_elder',
|
267 |
+
],
|
268 |
+
11:[
|
269 |
+
'Goal_11_Rating', 'Goal_11_Trend', 'Value_sdg11_slums', 'Year_sdg11_slums',
|
270 |
+
'impute_sdg11_slums', 'Score_sdg11_slums', 'Rating_sdg11_slums', 'Trend_sdg11_slums',
|
271 |
+
'Value_sdg11_pm25', 'Year_sdg11_pm25', 'Score_sdg11_pm25', 'Rating_sdg11_pm25',
|
272 |
+
'Trend_sdg11_pm25', 'Value_sdg11_pipedwat', 'Year_sdg11_pipedwat',
|
273 |
+
'Score_sdg11_pipedwat', 'Rating_sdg11_pipedwat', 'Trend_sdg11_pipedwat',
|
274 |
+
'Value_sdg11_transport', 'Year_sdg11_transport', 'Score_sdg11_transport',
|
275 |
+
'Rating_sdg11_transport', 'Trend_sdg11_transport', 'Value_sdg11_rentover',
|
276 |
+
'Year_sdg11_rentover', 'Rating_sdg11_rentover', 'Trend_sdg11_rentover',
|
277 |
+
'Value_sdg11_walkable', 'Year_sdg11_walkable', 'Rating_sdg11_walkable',
|
278 |
+
],
|
279 |
+
12:[
|
280 |
+
'Goal_12_Rating', 'Goal_12_Trend', 'Value_sdg12_waste', 'Year_sdg12_waste',
|
281 |
+
'impute_sdg12_waste', 'Score_sdg12_waste', 'Rating_sdg12_waste', 'Trend_sdg12_waste',
|
282 |
+
'Value_sdg12_recycling', 'Year_sdg12_recycling', 'impute_sdg12_recycling',
|
283 |
+
'Score_sdg12_recycling', 'Rating_sdg12_recycling', 'Trend_sdg12_recycling',
|
284 |
+
'Value_sdg12_solidwaste', 'Year_sdg12_solidwaste', 'impute_sdg12_solidwaste',
|
285 |
+
'Score_sdg12_solidwaste', 'Rating_sdg12_solidwaste', 'Trend_sdg12_solidwaste',
|
286 |
+
],
|
287 |
+
13:[
|
288 |
+
'Goal_13_Rating', 'Goal_13_Trend', 'Value_sdg13_emissions', 'Year_sdg13_emissions',
|
289 |
+
'impute_sdg13_emissions', 'Score_sdg13_emissions', 'Rating_sdg13_emissions',
|
290 |
+
'Trend_sdg13_emissions', 'Value_sdg13_forests', 'Year_sdg13_forests',
|
291 |
+
'impute_sdg13_forests', 'Score_sdg13_forests', 'Rating_sdg13_forests',
|
292 |
+
'Trend_sdg13_forests',
|
293 |
+
],
|
294 |
+
14:[
|
295 |
+
'Goal_14_Rating', 'Goal_14_Trend', 'Value_sdg14_overfishing', 'Year_sdg14_overfishing',
|
296 |
+
'impute_sdg14_overfishing', 'Score_sdg14_overfishing', 'Rating_sdg14_overfishing',
|
297 |
+
'Trend_sdg14_overfishing', 'Value_sdg14_mpa', 'Year_sdg14_mpa', 'impute_sdg14_mpa',
|
298 |
+
'Score_sdg14_mpa', 'Rating_sdg14_mpa', 'Trend_sdg14_mpa',
|
299 |
+
],
|
300 |
+
17:[
|
301 |
+
'Goal_17_Rating', 'Goal_17_Trend', 'Value_sdg17_govex', 'Year_sdg17_govex',
|
302 |
+
'Score_sdg17_govex', 'Rating_sdg17_govex', 'Trend_sdg17_govex', 'Value_sdg17_oda',
|
303 |
+
'Year_sdg17_oda', 'Score_sdg17_oda', 'Rating_sdg17_oda', 'Trend_sdg17_oda',
|
304 |
+
'Value_sdg17_fp', 'Year_sdg17_fp', 'impute_sdg17_fp', 'Score_sdg17_fp',
|
305 |
+
'Rating_sdg17_fp', 'Trend_sdg17_fp',
|
306 |
+
]
|
307 |
+
}
|
308 |
+
|
309 |
+
|
310 |
+
# Get the list of columns based on the selected SDG number
|
311 |
+
selected_columns = ['Country_Name'] + sdg_column_mapping.get(sdg_number, [])
|
312 |
+
|
313 |
+
# Filter data based on country and selected columns
|
314 |
+
selected_data = data[data['Name'] == country_name][selected_columns]
|
315 |
+
return selected_data
|
316 |
+
|
317 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio==4.9.0
|
2 |
+
gradio_client==0.7.2
|
3 |
+
uuid==1.30
|
4 |
+
pandas==1.3.3
|
5 |
+
gunicorn==20.0.4
|
user.png
ADDED
![]() |