Update app.py
Browse files
app.py
CHANGED
@@ -19,21 +19,21 @@ def load_and_clean_data():
|
|
19 |
|
20 |
# Concatenate dataframes and clean data
|
21 |
df_combined = pd.concat([df1, df2, df3, df4])
|
22 |
-
df_combined['Domain'] = df_combined['Domain'].replace("MUSLIM"
|
23 |
-
df_combined = df_combined[
|
24 |
-
|
25 |
-
|
26 |
-
df_combined = df_combined[
|
27 |
|
28 |
return df_combined
|
29 |
|
30 |
df = load_and_clean_data()
|
31 |
|
32 |
-
#
|
33 |
-
domain_options = df['Domain'].unique()
|
34 |
-
channel_options = df['Channel'].unique()
|
35 |
-
sentiment_options = df['Sentiment'].unique()
|
36 |
-
discrimination_options = df['Discrimination'].unique()
|
37 |
|
38 |
domain_filter = st.sidebar.multiselect('Select Domain', options=domain_options, default=domain_options)
|
39 |
channel_filter = st.sidebar.multiselect('Select Channel', options=channel_options, default=channel_options)
|
@@ -97,6 +97,7 @@ def create_channel_discrimination_chart(df):
|
|
97 |
fig.update_layout(title='Channel-wise Distribution of Discriminative Content', margin=dict(l=20, r=20, t=40, b=20))
|
98 |
return fig
|
99 |
|
|
|
100 |
def render_dashboard(page, df_filtered):
|
101 |
if page == "Overview":
|
102 |
st.title("Overview Dashboard")
|
@@ -115,13 +116,11 @@ def render_dashboard(page, df_filtered):
|
|
115 |
|
116 |
elif page == "Sentiment Analysis":
|
117 |
st.title("Sentiment Analysis Dashboard")
|
118 |
-
#
|
119 |
-
# Example: st.plotly_chart(create_some_other_chart(df_filtered))
|
120 |
|
121 |
elif page == "Discrimination Analysis":
|
122 |
st.title("Discrimination Analysis Dashboard")
|
123 |
-
#
|
124 |
-
# Example: st.plotly_chart(create_another_chart(df_filtered))
|
125 |
|
126 |
elif page == "Channel Analysis":
|
127 |
st.title("Channel Analysis Dashboard")
|
@@ -132,5 +131,5 @@ def render_dashboard(page, df_filtered):
|
|
132 |
with col2:
|
133 |
st.plotly_chart(create_channel_discrimination_chart(df_filtered))
|
134 |
|
135 |
-
# Render the dashboard
|
136 |
render_dashboard(page, df_filtered)
|
|
|
19 |
|
20 |
# Concatenate dataframes and clean data
|
21 |
df_combined = pd.concat([df1, df2, df3, df4])
|
22 |
+
df_combined['Domain'] = df_combined['Domain'].replace({"MUSLIM": "Muslim", "nan": pd.NA, "None": pd.NA, "Other-Ethnic": "Other-Ethnicity"})
|
23 |
+
df_combined['Sentiment'] = df_combined['Sentiment'].replace({"nan": pd.NA, "None": pd.NA, "No": pd.NA})
|
24 |
+
|
25 |
+
# Drop rows with NA values in 'Domain' and 'Sentiment'
|
26 |
+
df_combined = df_combined.dropna(subset=['Domain', 'Sentiment'])
|
27 |
|
28 |
return df_combined
|
29 |
|
30 |
df = load_and_clean_data()
|
31 |
|
32 |
+
# Sidebar Filters
|
33 |
+
domain_options = df['Domain'].dropna().unique()
|
34 |
+
channel_options = df['Channel'].dropna().unique()
|
35 |
+
sentiment_options = df['Sentiment'].dropna().unique()
|
36 |
+
discrimination_options = df['Discrimination'].dropna().unique()
|
37 |
|
38 |
domain_filter = st.sidebar.multiselect('Select Domain', options=domain_options, default=domain_options)
|
39 |
channel_filter = st.sidebar.multiselect('Select Channel', options=channel_options, default=channel_options)
|
|
|
97 |
fig.update_layout(title='Channel-wise Distribution of Discriminative Content', margin=dict(l=20, r=20, t=40, b=20))
|
98 |
return fig
|
99 |
|
100 |
+
# Function for rendering dashboard
|
101 |
def render_dashboard(page, df_filtered):
|
102 |
if page == "Overview":
|
103 |
st.title("Overview Dashboard")
|
|
|
116 |
|
117 |
elif page == "Sentiment Analysis":
|
118 |
st.title("Sentiment Analysis Dashboard")
|
119 |
+
# Implement sentiment analysis visualizations here
|
|
|
120 |
|
121 |
elif page == "Discrimination Analysis":
|
122 |
st.title("Discrimination Analysis Dashboard")
|
123 |
+
# Implement discrimination analysis visualizations here
|
|
|
124 |
|
125 |
elif page == "Channel Analysis":
|
126 |
st.title("Channel Analysis Dashboard")
|
|
|
131 |
with col2:
|
132 |
st.plotly_chart(create_channel_discrimination_chart(df_filtered))
|
133 |
|
134 |
+
# Render the selected dashboard page
|
135 |
render_dashboard(page, df_filtered)
|