File size: 16,293 Bytes
26004de
833e891
 
 
 
26004de
833e891
26004de
e84c461
833e891
 
 
e84c461
 
 
 
 
833e891
e84c461
833e891
 
 
e84c461
833e891
e84c461
833e891
e84c461
833e891
 
e84c461
833e891
 
e84c461
833e891
 
 
 
 
 
 
 
e84c461
 
 
833e891
e84c461
833e891
 
 
 
e84c461
833e891
 
e84c461
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
833e891
 
e84c461
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92cbdd1
 
 
 
 
 
 
 
 
 
 
 
 
d063987
 
 
 
 
26004de
d063987
26004de
 
d063987
26004de
d063987
b798eff
d063987
 
 
 
 
 
 
 
26004de
 
d063987
26004de
d063987
26004de
d063987
 
26004de
d063987
26004de
d063987
 
 
 
 
 
 
26004de
 
d063987
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26004de
d063987
26004de
d063987
 
 
26004de
d063987
26004de
d063987
26004de
d063987
26004de
d063987
 
26004de
d063987
26004de
d063987
 
 
 
 
 
26004de
d063987
26004de
d063987
26004de
d063987
26004de
d063987
 
 
 
26004de
d063987
26004de
d063987
26004de
d063987
26004de
d063987
26004de
d063987
26004de
d063987
26004de
d063987
 
 
 
26004de
 
d063987
26004de
d063987
 
26004de
d063987
26004de
2484a38
6af0a43
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
import streamlit as st
import pandas as pd
import plotly.express as px
import seaborn as sns
import matplotlib.pyplot as plt

st.title('Time Wasters on Social Media')


df = pd.read_csv('Time-Wasters on Social Media.csv')

st.subheader("Country-wise Addiction Levels by Demographics")
 
col1,col2=st.columns(2)
st.write("")
st.markdown("<hr>",unsafe_allow_html=True)
st.write("")
with col1:
    st.metric("Total Users",len(df['UserID'].unique().tolist()))
with col2:
    st.metric("Total Time Spent", int(df['Total Time Spent'].sum()))


selected_country = st.selectbox("Select Country", df['Location'].unique().tolist())

selected_gender = st.selectbox("Select Gender", df['Gender'].unique().tolist())

min_age, max_age = int(df['Age'].min()), int(df['Age'].max())
selected_age_range = st.slider("Select Age Range", min_age, max_age, (min_age, max_age))

selected_platform = st.selectbox("Select Platform", df['Platform'].unique().tolist())


filtered_data = df[
    (df['Location'] == selected_country) &
    (df['Gender'] == selected_gender) &
    (df['Age'] >= selected_age_range[0]) &
    (df['Age'] <= selected_age_range[1]) &
    (df['Platform'] == selected_platform)
]

# st.write(filtered_data)


avg_addiction_level = filtered_data['Addiction Level'].mean()

st.subheader(f"Average Addiction Level in {selected_country} for {selected_gender} users aged {selected_age_range[0]} to {selected_age_range[1]} on {selected_platform}:")
st.write(f"*{avg_addiction_level:.2f}*")

st.subheader("Addiction Level Distribution")

plt.figure(figsize=(10, 6))
sns.histplot(data=filtered_data, x='Addiction Level', kde=True, bins=10, color='teal')
plt.title(f"Addiction Level Distribution in {selected_country} for {selected_gender} users")
plt.xlabel('Addiction Level')
plt.ylabel('Frequency')

st.pyplot(plt)

#Time Spenditure Analysis
# platform=st.multiselect("Select Platforms",df['Platform'].unique().tolist())

# filter1_df= df[
#     (df['Platform'] == platform) & 
#     (df['Frequency']) & 
#     (df['Total Time Spent'])
# ]

# time_spent_on_platform=filter1_df[["Platform","Frequency","Total Time Spent"]].groupby(['Platform','Frequency']).sum().reset_index()
# pivot_time_spent_on_platform = pd.pivot(time_spent_on_platform,index='Frequency',columns='Platform',values='Total Time Spent')
# pivot_time_spent_on_platform.reset_index(inplace=True)
# pivot_time_spent_on_platform.set_index("Frequency", inplace=True)
# fig1,ax1=plt.subplots(figsize=(9, 7))
# ax1.plot(pivot_time_spent_on_platform,linestyle='--',marker='o')
# plt.xlabel('Frequency')
# plt.ylabel('Total Time Spent')
# plt.title('Multiline Line Plot from Pivot Table')
# plt.legend(df['Platform'],title='Platform',loc=2)
# ax1.grid(True)
# st.pyplot(fig1)
# st.write("")
# st.write("")
# st.markdown("<hr>",unsafe_allow_html=True)
# st.write("")
# st.write("")

watch_reason_counts = filtered_data['Watch Reason'].value_counts()

st.subheader("Most Common Watch Reasons")
st.write(watch_reason_counts)
st.subheader("Country-wise Engagement Levels")

avg_engagement_by_country = df.groupby('Location')['Engagement'].mean().sort_values(ascending=False)

st.bar_chart(avg_engagement_by_country)

st.subheader("Addiction Level vs Age")

selected_country = st.selectbox("Select Country", df['Location'].unique(), key='country_select_addiction')
selected_platform = st.selectbox("Select Platform", df['Platform'].unique(), key='platform_select_addiction')

filtered_data = df[(df['Location'] == selected_country) & (df['Platform'] == selected_platform)]

plt.figure(figsize=(10, 6))
sns.lineplot(data=filtered_data, x='Age', y='Addiction Level', marker='o')
plt.title(f'Addiction Level vs Age in {selected_country} on {selected_platform}')
plt.xlabel('Age')
plt.ylabel('Addiction Level')
st.pyplot(plt)

st.subheader("Engagement Levels by Platform")

age_range = st.slider("Select Age Range", int(df['Age'].min()), int(df['Age'].max()), (20, 40), key='age_slider_platform')

filtered_data = df[(df['Age'] >= age_range[0]) & (df['Age'] <= age_range[1])]

plt.figure(figsize=(10, 6))
sns.boxplot(data=filtered_data, x='Platform', y='Engagement', palette='Set3')
plt.title(f'Engagement Levels for Age Group {age_range[0]} to {age_range[1]}')
st.pyplot(plt)

st.subheader("Gender-wise Comparison of Productivity Loss")

selected_platform = st.selectbox("Select Platform", df['Platform'].unique(), key='platform_select_prod_loss')

filtered_data = df[df['Platform'] == selected_platform]

gender_prod_loss = filtered_data.groupby('Gender')['ProductivityLoss'].mean()

st.bar_chart(gender_prod_loss)

st.subheader("Engagement vs Productivity Loss")

plt.figure(figsize=(10, 6))
sns.scatterplot(data=df, x='Engagement', y='ProductivityLoss', hue='Platform', palette='viridis', s=100)
plt.title('Engagement vs Productivity Loss across Platforms')
st.pyplot(plt)


st.subheader("Watch Reasons per Demographic")

selected_country = st.selectbox("Select Country", df['Location'].unique(), key='country_select_watch_reason')
age_range = st.slider("Select Age Range", int(df['Age'].min()), int(df['Age'].max()), (20, 40), key='age_slider_watch_reason')

filtered_data = df[(df['Location'] == selected_country) & (df['Age'] >= age_range[0]) & (df['Age'] <= age_range[1])]

watch_reasons = filtered_data['Watch Reason'].value_counts()
st.bar_chart(watch_reasons)


# import streamlit as st
# import pandas as pd
# import plotly.express as px
# import seaborn as sns
# import matplotlib.pyplot as plt

# # Custom CSS for Stunning UI
# st.markdown(
#     """
#     <style>
#         /* Background Gradient */
#         body {
#             background: linear-gradient(to right, #0f2027, #203a43, #2c5364);
#             color: white;
#         }
        
#         /* Main Title Styling */
#         .main-title {
#             text-align: center;
#             color: #ffffff;
#             font-size: 60px;
#             font-weight: bold;
#             text-shadow: 3px 3px 15px rgba(255,255,255,0.3);
#         }
        
#         /* Subtitle Styling */
#         .subtitle {
#             text-align: center;
#             color: #d1d1d1;
#             font-size: 38px;
#             font-style: italic;
#         }
        
#         /* Glassmorphism Card Effect */
#         .content-box {
#             background: rgba(255, 255, 255, 0.15);
#             padding: 25px;
#             border-radius: 20px;
#             backdrop-filter: blur(12px);
#             box-shadow: 4px 6px 15px rgba(0,0,0,0.2);
#             margin: 25px;
#         }
        
#         /* List Styling */
#         .list-item {
#             color: #FFD700;
#             font-size: 28px;
#             padding: 8px;
#             transition: transform 0.3s, color 0.3s;
#         }
#         .list-item:hover {
#             color: #FF4500;
#             transform: scale(1.08);
#         }
        
#         /* Stylish Buttons */
#         .stButton>button {
#             background: linear-gradient(to right, #ff7e5f, #feb47b);
#             color: white;
#             font-size: 20px;
#             border-radius: 10px;
#             padding: 14px 22px;
#             transition: all 0.3s ease-in-out;
#             border: none;
#         }
#         .stButton>button:hover {
#             background: linear-gradient(to right, #feb47b, #ff7e5f);
#             transform: scale(1.12);
#         }
#     </style>
#     """,
#     unsafe_allow_html=True
# )

# # Display Title
# st.markdown("<h1 class='main-title'> Welcome to the Time-Wasters on Social Media Analytics</h1>", unsafe_allow_html=True)

# st.write("")

# # Display Subtitle
# st.markdown("<h3 class='subtitle'> Dive into the insights of Social Media Engagement and Addiction.</h3>", unsafe_allow_html=True)

# st.write("")

# # Content Section with Glassmorphism
# st.markdown(
#     """
#     <div class='content-box'>
#         <h4 style='color: #ffffff; font-size: 40px;'>🔍 What You Will Discover:</h4>
#         <ol>
#             <li class='list-item'> Analysis of Users and their activity over Social Media</li>
#             <li class='list-item'> Engagement Levels of Users over Social Media</li>
#             <li class='list-item'> Addiction Levels of Users over Social Media</li>
#         </ol>
#     </div>
#     """, 
#     unsafe_allow_html=True
# )

# # Call-to-Action Button
# if st.button(" Explore Dashboard "):
#     st.switch_page("dashboard.py")  # Ensure 'dashboard.py' exists as the main dashboard page

# # --- KEEPING PLOTTING AND FUNCTIONALITY UNTOUCHED BELOW ---

# st.title('Time Wasters on Social Media')

# df = pd.read_csv('Time-Wasters on Social Media.csv')

# st.subheader("Country-wise Addiction Levels by Demographics")

# col1, col2 = st.columns(2)
# with col1:
#     st.metric("Total Users", len(df['UserID'].unique().tolist()))
# with col2:
#     st.metric("Total Time Spent", int(df['Total Time Spent'].sum()))

# selected_country = st.selectbox("Select Country", df['Location'].unique().tolist())
# selected_gender = st.selectbox("Select Gender", df['Gender'].unique().tolist())
# min_age, max_age = int(df['Age'].min()), int(df['Age'].max())
# selected_age_range = st.slider("Select Age Range", min_age, max_age, (min_age, max_age))
# selected_platform = st.selectbox("Select Platform", df['Platform'].unique().tolist())

# filtered_data = df[
#     (df['Location'] == selected_country) &
#     (df['Gender'] == selected_gender) &
#     (df['Age'] >= selected_age_range[0]) &
#     (df['Age'] <= selected_age_range[1]) &
#     (df['Platform'] == selected_platform)
# ]

# avg_addiction_level = filtered_data['Addiction Level'].mean()
# st.subheader(f"Average Addiction Level in {selected_country} for {selected_gender} users aged {selected_age_range[0]} to {selected_age_range[1]} on {selected_platform}:")
# st.write(f"*{avg_addiction_level:.2f}*")

# st.subheader("Addiction Level Distribution")
# plt.figure(figsize=(10, 6))
# sns.histplot(data=filtered_data, x='Addiction Level', kde=True, bins=10, color='teal')
# st.pyplot(plt)

# watch_reason_counts = filtered_data['Watch Reason'].value_counts()
# st.subheader("Most Common Watch Reasons")
# st.write(watch_reason_counts)
# st.subheader("Country-wise Engagement Levels")
# avg_engagement_by_country = df.groupby('Location')['Engagement'].mean().sort_values(ascending=False)
# st.bar_chart(avg_engagement_by_country)

# st.subheader("Addiction Level vs Age")
# selected_country = st.selectbox("Select Country", df['Location'].unique(), key='country_select_addiction')
# selected_platform = st.selectbox("Select Platform", df['Platform'].unique(), key='platform_select_addiction')
# filtered_data = df[(df['Location'] == selected_country) & (df['Platform'] == selected_platform)]
# sns.lineplot(data=filtered_data, x='Age', y='Addiction Level', marker='o')
# st.pyplot(plt)
# import streamlit as st
# import pandas as pd
# import plotly.express as px
# import seaborn as sns
# import matplotlib.pyplot as plt

# st.title('Time Wasters on Social Media')


# df = pd.read_csv('Time-Wasters on Social Media.csv')

# st.subheader("Country-wise Addiction Levels by Demographics")
 
# col1,col2=st.columns(2)
# st.write("")
# st.markdown("<hr>",unsafe_allow_html=True)
# st.write("")
# with col1:
#     st.metric("Total Users",len(df['UserID'].unique().tolist()))
# with col2:
#     st.metric("Total Time Spent", int(df['Total Time Spent'].sum()))


# selected_country = st.selectbox("Select Country", df['Location'].unique().tolist())

# selected_gender = st.selectbox("Select Gender", df['Gender'].unique().tolist())

# min_age, max_age = int(df['Age'].min()), int(df['Age'].max())
# selected_age_range = st.slider("Select Age Range", min_age, max_age, (min_age, max_age))

# selected_platform = st.selectbox("Select Platform", df['Platform'].unique().tolist())


# filtered_data = df[
#     (df['Location'] == selected_country) &
#     (df['Gender'] == selected_gender) &
#     (df['Age'] >= selected_age_range[0]) &
#     (df['Age'] <= selected_age_range[1]) &
#     (df['Platform'] == selected_platform)
# ]

# # st.write(filtered_data)


# avg_addiction_level = filtered_data['Addiction Level'].mean()

# st.subheader(f"Average Addiction Level in {selected_country} for {selected_gender} users aged {selected_age_range[0]} to {selected_age_range[1]} on {selected_platform}:")
# st.write(f"*{avg_addiction_level:.2f}*")

# st.subheader("Addiction Level Distribution")

# plt.figure(figsize=(10, 6))
# sns.histplot(data=filtered_data, x='Addiction Level', kde=True, bins=10, color='teal')
# plt.title(f"Addiction Level Distribution in {selected_country} for {selected_gender} users")
# plt.xlabel('Addiction Level')
# plt.ylabel('Frequency')

# st.pyplot(plt)

# #Time Spenditure Analysis
# # platform=st.multiselect("Select Platforms",df['Platform'].unique().tolist())

# # filter1_df= df[
# #     (df['Platform'] == platform) & 
# #     (df['Frequency']) & 
# #     (df['Total Time Spent'])
# # ]

# # time_spent_on_platform=filter1_df[["Platform","Frequency","Total Time Spent"]].groupby(['Platform','Frequency']).sum().reset_index()
# # pivot_time_spent_on_platform = pd.pivot(time_spent_on_platform,index='Frequency',columns='Platform',values='Total Time Spent')
# # pivot_time_spent_on_platform.reset_index(inplace=True)
# # pivot_time_spent_on_platform.set_index("Frequency", inplace=True)
# # fig1,ax1=plt.subplots(figsize=(9, 7))
# # ax1.plot(pivot_time_spent_on_platform,linestyle='--',marker='o')
# # plt.xlabel('Frequency')
# # plt.ylabel('Total Time Spent')
# # plt.title('Multiline Line Plot from Pivot Table')
# # plt.legend(df['Platform'],title='Platform',loc=2)
# # ax1.grid(True)
# # st.pyplot(fig1)
# # st.write("")
# # st.write("")
# # st.markdown("<hr>",unsafe_allow_html=True)
# # st.write("")
# # st.write("")

# watch_reason_counts = filtered_data['Watch Reason'].value_counts()

# st.subheader("Most Common Watch Reasons")
# st.write(watch_reason_counts)
# st.subheader("Country-wise Engagement Levels")

# avg_engagement_by_country = df.groupby('Location')['Engagement'].mean().sort_values(ascending=False)

# st.bar_chart(avg_engagement_by_country)

# st.subheader("Addiction Level vs Age")

# selected_country = st.selectbox("Select Country", df['Location'].unique(), key='country_select_addiction')
# selected_platform = st.selectbox("Select Platform", df['Platform'].unique(), key='platform_select_addiction')

# filtered_data = df[(df['Location'] == selected_country) & (df['Platform'] == selected_platform)]

# plt.figure(figsize=(10, 6))
# sns.lineplot(data=filtered_data, x='Age', y='Addiction Level', marker='o')
# plt.title(f'Addiction Level vs Age in {selected_country} on {selected_platform}')
# plt.xlabel('Age')
# plt.ylabel('Addiction Level')
# st.pyplot(plt)

# st.subheader("Engagement Levels by Platform")

# age_range = st.slider("Select Age Range", int(df['Age'].min()), int(df['Age'].max()), (20, 40), key='age_slider_platform')

# filtered_data = df[(df['Age'] >= age_range[0]) & (df['Age'] <= age_range[1])]

# plt.figure(figsize=(10, 6))
# sns.boxplot(data=filtered_data, x='Platform', y='Engagement', palette='Set3')
# plt.title(f'Engagement Levels for Age Group {age_range[0]} to {age_range[1]}')
# st.pyplot(plt)

# st.subheader("Gender-wise Comparison of Productivity Loss")

# selected_platform = st.selectbox("Select Platform", df['Platform'].unique(), key='platform_select_prod_loss')

# filtered_data = df[df['Platform'] == selected_platform]

# gender_prod_loss = filtered_data.groupby('Gender')['ProductivityLoss'].mean()

# st.bar_chart(gender_prod_loss)

# st.subheader("Engagement vs Productivity Loss")

# plt.figure(figsize=(10, 6))
# sns.scatterplot(data=df, x='Engagement', y='ProductivityLoss', hue='Platform', palette='viridis', s=100)
# plt.title('Engagement vs Productivity Loss across Platforms')
# st.pyplot(plt)


# st.subheader("Watch Reasons per Demographic")

# selected_country = st.selectbox("Select Country", df['Location'].unique(), key='country_select_watch_reason')
# age_range = st.slider("Select Age Range", int(df['Age'].min()), int(df['Age'].max()), (20, 40), key='age_slider_watch_reason')

# filtered_data = df[(df['Location'] == selected_country) & (df['Age'] >= age_range[0]) & (df['Age'] <= age_range[1])]

watch_reasons = filtered_data['Watch Reason'].value_counts()
# st.bar_chart(watch_reasons)