Update app.py
Browse files
app.py
CHANGED
@@ -10,11 +10,27 @@ import plotly.graph_objects as go
|
|
10 |
# Set page configuration
|
11 |
st.set_page_config(layout="wide")
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
# Normalize Text
|
20 |
df1['Domain'].replace("MUSLIM", "Muslim", inplace=True)
|
@@ -100,14 +116,22 @@ def render_dashboard():
|
|
100 |
|
101 |
# ... [Other pages]
|
102 |
|
103 |
-
# Sidebar Filters
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
# Render the dashboard with filtered data
|
113 |
render_dashboard(df_filtered)
|
|
|
10 |
# Set page configuration
|
11 |
st.set_page_config(layout="wide")
|
12 |
|
13 |
+
|
14 |
+
def load_and_clean_data():
|
15 |
+
df1 = pd.read_csv("data/reviewed_social_media_english.csv")
|
16 |
+
df2 = pd.read_csv("data/reviewed_news_english.csv")
|
17 |
+
df3 = pd.read_csv("data/tamil_social_media.csv")
|
18 |
+
df4 = pd.read_csv("data/tamil_news.csv")
|
19 |
+
|
20 |
+
# Normalize Text and Drop irrelevant data
|
21 |
+
frames = [df1, df2, df3, df4]
|
22 |
+
for frame in frames:
|
23 |
+
frame['Domain'].replace("MUSLIM", "Muslim", inplace=True)
|
24 |
+
frame.drop(frame[frame['Domain'] == 'Not relevant'].index, inplace=True)
|
25 |
+
frame.drop(frame[frame['Domain'] == 'None'].index, inplace=True)
|
26 |
+
frame.drop(frame[frame['Discrimination'] == 'None'].index, inplace=True)
|
27 |
+
frame.drop(frame[frame['Sentiment'] == 'None'].index, inplace=True)
|
28 |
+
|
29 |
+
# Concatenate/merge dataframes
|
30 |
+
df_combined = pd.concat(frames)
|
31 |
+
return df_combined
|
32 |
+
|
33 |
+
df = load_and_clean_data()
|
34 |
|
35 |
# Normalize Text
|
36 |
df1['Domain'].replace("MUSLIM", "Muslim", inplace=True)
|
|
|
116 |
|
117 |
# ... [Other pages]
|
118 |
|
119 |
+
# Define Sidebar Filters
|
120 |
+
domain_options = df['Domain'].unique()
|
121 |
+
channel_options = df['Channel'].unique()
|
122 |
+
sentiment_options = df['Sentiment'].unique()
|
123 |
+
discrimination_options = df['Discrimination'].unique()
|
124 |
+
|
125 |
+
domain_filter = st.sidebar.multiselect('Select Domain', options=domain_options, default=domain_options)
|
126 |
+
channel_filter = st.sidebar.multiselect('Select Channel', options=channel_options, default=channel_options)
|
127 |
+
sentiment_filter = st.sidebar.multiselect('Select Sentiment', options=sentiment_options, default=sentiment_options)
|
128 |
+
discrimination_filter = st.sidebar.multiselect('Select Discrimination', options=discrimination_options, default=discrimination_options)
|
129 |
+
|
130 |
+
# Apply the filters to the dataframe
|
131 |
+
df_filtered = df[(df['Domain'].isin(domain_filter)) &
|
132 |
+
(df['Channel'].isin(channel_filter)) &
|
133 |
+
(df['Sentiment'].isin(sentiment_filter)) &
|
134 |
+
(df['Discrimination'].isin(discrimination_filter))]
|
135 |
|
136 |
# Render the dashboard with filtered data
|
137 |
render_dashboard(df_filtered)
|