alvi15tooba commited on
Commit
f3fe48e
1 Parent(s): 99d14dd

Update app.py

Browse files

Added file path

Files changed (1) hide show
  1. app.py +29 -29
app.py CHANGED
@@ -1,29 +1,29 @@
1
- import pandas as pd
2
- import pygwalker as pyg
3
- import gradio as gr
4
-
5
- df = pd.read_csv("C:\\Users\\tooba.alvi\\OneDrive - Aga Khan University\\Documents\\GitHub\\PyG Walker\\WorldBank.csv", encoding= "utf-8")
6
-
7
- # Define a function to create the dashboard
8
- '''def create_dashboard():
9
- df = pd.read_csv("C:\\Users\\tooba.alvi\\OneDrive - Aga Khan University\\Documents\\GitHub\\PyG Walker\\WorldBank.csv", encoding= "utf-8")
10
- pyg.walk(df)
11
- return pyg.get_html()
12
- '''
13
- def display_data():
14
- df = pd.read_csv("C:\\Users\\tooba.alvi\\OneDrive - Aga Khan University\\Documents\\GitHub\\PyG Walker\\WorldBank.csv", encoding= "utf-8")
15
- df=pd.DataFrame(df)
16
- pyg.walk(df)
17
- pyg_html = pyg.to_html(df)
18
- vis_spec=r"""{"config":[{"config":{"defaultAggregated":true,"geoms":["auto"],"coordSystem":"generic","limit":-1,"timezoneDisplayOffset":0},"encodings":{"dimensions":[{"fid":"Year","name":"Year","basename":"Year","analyticType":"dimension","semanticType":"ordinal","aggName":"sum","offset":0},{"fid":"Country Name","name":"Country Name","basename":"Country Name","semanticType":"nominal","analyticType":"dimension","offset":0},{"fid":"Country Code","name":"Country Code","basename":"Country Code","semanticType":"nominal","analyticType":"dimension","offset":0},{"fid":"Region","name":"Region","basename":"Region","semanticType":"nominal","analyticType":"dimension","offset":0},{"fid":"IncomeGroup","name":"IncomeGroup","basename":"IncomeGroup","semanticType":"nominal","analyticType":"dimension","offset":0},{"fid":"gw_mea_key_fid","name":"Measure names","analyticType":"dimension","semanticType":"nominal"}],"measures":[{"fid":"Birth rate, crude (per 1,000 people)","name":"Birth rate, crude (per 1,000 people)","basename":"Birth rate, crude (per 1,000 people)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"Death rate, crude (per 1,000 people)","name":"Death rate, crude (per 1,000 people)","basename":"Death rate, crude (per 1,000 people)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"Electric power consumption (kWh per capita)","name":"Electric power consumption (kWh per capita)","basename":"Electric power consumption (kWh per capita)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"GDP (USD)","name":"GDP (USD)","basename":"GDP (USD)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"GDP per capita (USD)","name":"GDP per capita (USD)","basename":"GDP per capita (USD)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"Individuals using the Internet (% of population)","name":"Individuals using the Internet (% of population)","basename":"Individuals using the Internet (% of population)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"Infant mortality rate (per 1,000 live births)","name":"Infant mortality rate (per 1,000 live births)","basename":"Infant mortality rate (per 1,000 live births)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"Life expectancy at birth (years)","name":"Life expectancy at birth (years)","basename":"Life expectancy at birth (years)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"Population density (people per sq. km of land area)","name":"Population density (people per sq. km of land area)","basename":"Population density (people per sq. km of land area)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"Unemployment (% of total labor force) (modeled ILO estimate)","name":"Unemployment (% of total labor force) (modeled ILO estimate)","basename":"Unemployment (% of total labor force) (modeled ILO estimate)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"gw_count_fid","name":"Row count","analyticType":"measure","semanticType":"quantitative","aggName":"sum","computed":true,"expression":{"op":"one","params":[],"as":"gw_count_fid"}},{"fid":"gw_mea_val_fid","name":"Measure values","analyticType":"measure","semanticType":"quantitative","aggName":"sum"}],"rows":[{"fid":"Birth rate, crude (per 1,000 people)","name":"Birth rate, crude (per 1,000 people)","basename":"Birth rate, crude (per 1,000 people)","analyticType":"measure","semanticType":"quantitative","aggName":"mean","offset":0}],"columns":[{"fid":"Year","name":"Year","basename":"Year","analyticType":"dimension","semanticType":"ordinal","aggName":"sum","offset":0}],"color":[{"fid":"IncomeGroup","name":"IncomeGroup","basename":"IncomeGroup","semanticType":"nominal","analyticType":"dimension","offset":0}],"opacity":[],"size":[],"shape":[],"radius":[],"theta":[],"longitude":[],"latitude":[],"geoId":[],"details":[],"filters":[{"fid":"IncomeGroup","name":"IncomeGroup","basename":"IncomeGroup","semanticType":"nominal","analyticType":"dimension","offset":0,"rule":null}],"text":[]},"layout":{"showActions":false,"showTableSummary":false,"stack":"stack","interactiveScale":false,"zeroScale":true,"size":{"mode":"auto","width":320,"height":200},"format":{},"geoKey":"name","resolve":{"x":false,"y":false,"color":false,"opacity":false,"shape":false,"size":false}},"visId":"gw_DGUp","name":"Chart 1"}],"chart_map":{},"workflow_list":[{"workflow":[{"type":"view","query":[{"op":"aggregate","groupBy":["Year","IncomeGroup"],"measures":[{"field":"Birth rate, crude (per 1,000 people)","agg":"mean","asFieldKey":"Birth rate, crude (per 1,000 people)_mean"}]}]}]}],"version":"0.4.8.10"}"""
19
- return pyg_html
20
-
21
-
22
- # Create a Gradio interface
23
- interface = gr.Interface(fn=display_data,
24
- inputs=[],
25
- outputs="html",
26
- title="My Dashboard with PyG Walker")
27
-
28
- # Launch the interface
29
- interface.launch()
 
1
+ import pandas as pd
2
+ import pygwalker as pyg
3
+ import gradio as gr
4
+
5
+ df = pd.read_csv("WorldBank.csv", encoding= "utf-8")
6
+
7
+ # Define a function to create the dashboard
8
+ '''def create_dashboard():
9
+ df = pd.read_csv("C:\\Users\\tooba.alvi\\OneDrive - Aga Khan University\\Documents\\GitHub\\PyG Walker\\WorldBank.csv", encoding= "utf-8")
10
+ pyg.walk(df)
11
+ return pyg.get_html()
12
+ '''
13
+ def display_data():
14
+ df = pd.read_csv("C:\\Users\\tooba.alvi\\OneDrive - Aga Khan University\\Documents\\GitHub\\PyG Walker\\WorldBank.csv", encoding= "utf-8")
15
+ df=pd.DataFrame(df)
16
+ pyg.walk(df)
17
+ pyg_html = pyg.to_html(df)
18
+ vis_spec=r"""{"config":[{"config":{"defaultAggregated":true,"geoms":["auto"],"coordSystem":"generic","limit":-1,"timezoneDisplayOffset":0},"encodings":{"dimensions":[{"fid":"Year","name":"Year","basename":"Year","analyticType":"dimension","semanticType":"ordinal","aggName":"sum","offset":0},{"fid":"Country Name","name":"Country Name","basename":"Country Name","semanticType":"nominal","analyticType":"dimension","offset":0},{"fid":"Country Code","name":"Country Code","basename":"Country Code","semanticType":"nominal","analyticType":"dimension","offset":0},{"fid":"Region","name":"Region","basename":"Region","semanticType":"nominal","analyticType":"dimension","offset":0},{"fid":"IncomeGroup","name":"IncomeGroup","basename":"IncomeGroup","semanticType":"nominal","analyticType":"dimension","offset":0},{"fid":"gw_mea_key_fid","name":"Measure names","analyticType":"dimension","semanticType":"nominal"}],"measures":[{"fid":"Birth rate, crude (per 1,000 people)","name":"Birth rate, crude (per 1,000 people)","basename":"Birth rate, crude (per 1,000 people)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"Death rate, crude (per 1,000 people)","name":"Death rate, crude (per 1,000 people)","basename":"Death rate, crude (per 1,000 people)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"Electric power consumption (kWh per capita)","name":"Electric power consumption (kWh per capita)","basename":"Electric power consumption (kWh per capita)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"GDP (USD)","name":"GDP (USD)","basename":"GDP (USD)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"GDP per capita (USD)","name":"GDP per capita (USD)","basename":"GDP per capita (USD)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"Individuals using the Internet (% of population)","name":"Individuals using the Internet (% of population)","basename":"Individuals using the Internet (% of population)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"Infant mortality rate (per 1,000 live births)","name":"Infant mortality rate (per 1,000 live births)","basename":"Infant mortality rate (per 1,000 live births)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"Life expectancy at birth (years)","name":"Life expectancy at birth (years)","basename":"Life expectancy at birth (years)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"Population density (people per sq. km of land area)","name":"Population density (people per sq. km of land area)","basename":"Population density (people per sq. km of land area)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"Unemployment (% of total labor force) (modeled ILO estimate)","name":"Unemployment (% of total labor force) (modeled ILO estimate)","basename":"Unemployment (% of total labor force) (modeled ILO estimate)","analyticType":"measure","semanticType":"quantitative","aggName":"sum","offset":0},{"fid":"gw_count_fid","name":"Row count","analyticType":"measure","semanticType":"quantitative","aggName":"sum","computed":true,"expression":{"op":"one","params":[],"as":"gw_count_fid"}},{"fid":"gw_mea_val_fid","name":"Measure values","analyticType":"measure","semanticType":"quantitative","aggName":"sum"}],"rows":[{"fid":"Birth rate, crude (per 1,000 people)","name":"Birth rate, crude (per 1,000 people)","basename":"Birth rate, crude (per 1,000 people)","analyticType":"measure","semanticType":"quantitative","aggName":"mean","offset":0}],"columns":[{"fid":"Year","name":"Year","basename":"Year","analyticType":"dimension","semanticType":"ordinal","aggName":"sum","offset":0}],"color":[{"fid":"IncomeGroup","name":"IncomeGroup","basename":"IncomeGroup","semanticType":"nominal","analyticType":"dimension","offset":0}],"opacity":[],"size":[],"shape":[],"radius":[],"theta":[],"longitude":[],"latitude":[],"geoId":[],"details":[],"filters":[{"fid":"IncomeGroup","name":"IncomeGroup","basename":"IncomeGroup","semanticType":"nominal","analyticType":"dimension","offset":0,"rule":null}],"text":[]},"layout":{"showActions":false,"showTableSummary":false,"stack":"stack","interactiveScale":false,"zeroScale":true,"size":{"mode":"auto","width":320,"height":200},"format":{},"geoKey":"name","resolve":{"x":false,"y":false,"color":false,"opacity":false,"shape":false,"size":false}},"visId":"gw_DGUp","name":"Chart 1"}],"chart_map":{},"workflow_list":[{"workflow":[{"type":"view","query":[{"op":"aggregate","groupBy":["Year","IncomeGroup"],"measures":[{"field":"Birth rate, crude (per 1,000 people)","agg":"mean","asFieldKey":"Birth rate, crude (per 1,000 people)_mean"}]}]}]}],"version":"0.4.8.10"}"""
19
+ return pyg_html
20
+
21
+
22
+ # Create a Gradio interface
23
+ interface = gr.Interface(fn=display_data,
24
+ inputs=[],
25
+ outputs="html",
26
+ title="My Dashboard with PyG Walker")
27
+
28
+ # Launch the interface
29
+ interface.launch()