harshidagli commited on
Commit
6e1191d
·
verified ·
1 Parent(s): 0fa4ba3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -51
app.py CHANGED
@@ -39,59 +39,35 @@ world_map = alt.topo_feature(data.world_110m.url, feature='countries')
39
  from iso3166 import countries_by_name
40
  '''
41
 
42
- import ipywidgets as widgets
43
- from IPython.display import display, clear_output
44
-
45
- alt.data_transformers.disable_max_rows()
46
 
47
- url = "contract_awards_in_investment_project_financing_22-11-2024.csv"
48
  df = pd.read_csv(url)
49
 
50
  numeric_columns = df.select_dtypes(include=['float64', 'int64']).columns
51
-
52
- col1_dropdown = widgets.Dropdown(
53
- options=numeric_columns,
54
- value=numeric_columns[0],
55
- description="Column 1:"
56
- )
57
-
58
- col2_dropdown = widgets.Dropdown(
59
- options=numeric_columns,
60
- value=numeric_columns[1],
61
- description="Column 2:"
 
 
 
 
 
 
 
 
 
 
 
62
  )
63
-
64
- output = widgets.Output()
65
-
66
- def update_correlation(change):
67
- with output:
68
- clear_output(wait=True)
69
-
70
- col1 = col1_dropdown.value
71
- col2 = col2_dropdown.value
72
-
73
- correlation_value = df[col1].corr(df[col2])
74
- print(f"Correlation between {col1} and {col2}: {correlation_value:.2f}")
75
-
76
- correlation_plot = (
77
- alt.Chart(df)
78
- .mark_circle(size=60)
79
- .encode(
80
- x=alt.X(f"{col1}:Q", title=col1),
81
- y=alt.Y(f"{col2}:Q", title=col2),
82
- color="Region:N",
83
- tooltip=["Project Name", "Supplier", col1, col2],
84
- )
85
- .properties(
86
- title=f"Correlation Plot: {col1} vs. {col2}",
87
- width=600,
88
- height=400
89
- )
90
- )
91
- display(correlation_plot)
92
-
93
- col1_dropdown.observe(update_correlation, names='value')
94
- col2_dropdown.observe(update_correlation, names='value')
95
-
96
- print("Select columns for correlation analysis:")
97
- display(col1_dropdown, col2_dropdown, output)
 
39
  from iso3166 import countries_by_name
40
  '''
41
 
42
+ import streamlit as st
43
+ import pandas as pd
44
+ import altair as alt
 
45
 
46
+ url = "/Users/sharanya/Documents/SEMESTERS/7- FALL 2024/IS445/FinalProject/IS445_VizForExperts/contract_awards_in_investment_project_financing.csv"
47
  df = pd.read_csv(url)
48
 
49
  numeric_columns = df.select_dtypes(include=['float64', 'int64']).columns
50
+ st.header("Correlation Analysis")
51
+
52
+ col1 = st.selectbox("Select First Numeric Attribute", numeric_columns, index=0)
53
+ col2 = st.selectbox("Select Second Numeric Attribute", numeric_columns, index=1)
54
+
55
+ correlation_value = df[col1].corr(df[col2])
56
+ st.write(f"**Correlation between {col1} and {col2}: {correlation_value:.2f}**")
57
+
58
+ correlation_plot = (
59
+ alt.Chart(df)
60
+ .mark_circle(size=60)
61
+ .encode(
62
+ x=alt.X(f"{col1}:Q", title=col1),
63
+ y=alt.Y(f"{col2}:Q", title=col2),
64
+ color="Region:N", # Color by region for additional context
65
+ tooltip=["Project Name", "Supplier", col1, col2],
66
+ )
67
+ .properties(
68
+ title=f"Correlation Plot: {col1} vs. {col2}",
69
+ width=600,
70
+ height=400
71
+ )
72
  )
73
+ st.altair_chart(correlation_plot, use_container_width=True)