Spaces:
Sleeping
Sleeping
Ezhil commited on
Commit ·
6ce9997
1
Parent(s): ae0267c
added the spotify logo
Browse files- app.py +32 -17
- models/__pycache__/data_processor.cpython-310.pyc +0 -0
- models/data_processor.py +1 -1
app.py
CHANGED
|
@@ -1,26 +1,36 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
from models.data_processor import load_data
|
| 4 |
-
from functions.visualizations import
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
|
|
|
|
| 9 |
df = load_data()
|
| 10 |
-
if not df.empty:
|
| 11 |
-
st.write("**Raw Data Sample:**", df.head())
|
| 12 |
-
else:
|
| 13 |
-
st.error("Failed to load raw data. Check the 'data/music_data.csv' file.")
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
st.sidebar.title("Music Data Analysis")
|
| 16 |
-
|
| 17 |
-
|
|
|
|
| 18 |
analysis_option = st.sidebar.selectbox(
|
| 19 |
"Choose Analysis",
|
| 20 |
-
[
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
| 24 |
)
|
| 25 |
|
| 26 |
st.sidebar.subheader("Filters")
|
|
@@ -33,10 +43,17 @@ else:
|
|
| 33 |
"No data loaded or 'Decade' column missing. Check the 'data' folder.")
|
| 34 |
filtered_df = pd.DataFrame()
|
| 35 |
|
| 36 |
-
#
|
| 37 |
st.title("Music Data Analysis Dashboard")
|
| 38 |
st.markdown("Explore trends and insights from a diverse music dataset.")
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
if analysis_option == "Popularity Trends Over Time":
|
| 41 |
generate_popularity_trends(filtered_df)
|
| 42 |
elif analysis_option == "Audio Features Analysis":
|
|
@@ -61,5 +78,3 @@ elif analysis_option == "Feature Comparisons Across Decades":
|
|
| 61 |
generate_feature_comparisons(filtered_df)
|
| 62 |
elif analysis_option == "Network Analysis":
|
| 63 |
generate_network_analysis(filtered_df)
|
| 64 |
-
|
| 65 |
-
# st.sidebar.markdown("Built with Streamlit by Grok 3 (xAI)")
|
|
|
|
| 1 |
+
import os
|
| 2 |
import streamlit as st
|
| 3 |
import pandas as pd
|
| 4 |
from models.data_processor import load_data
|
| 5 |
+
from functions.visualizations import (
|
| 6 |
+
generate_popularity_trends, generate_audio_features, generate_genre_analysis,
|
| 7 |
+
generate_explicit_trends, generate_album_insights, generate_tempo_mood,
|
| 8 |
+
generate_top_artists_songs, generate_album_release_trends, generate_duration_analysis,
|
| 9 |
+
generate_streaming_insights, generate_feature_comparisons, generate_network_analysis
|
| 10 |
+
)
|
| 11 |
|
| 12 |
+
# Load Data
|
| 13 |
df = load_data()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
# Sidebar - Add Spotify Logo from Local File
|
| 16 |
+
logo_path = "assests/spotify-logo.png" # Adjust this if needed
|
| 17 |
+
if os.path.exists(logo_path):
|
| 18 |
+
st.sidebar.image(logo_path, use_column_width=True)
|
| 19 |
+
|
| 20 |
+
# Sidebar - Title & Filters
|
| 21 |
st.sidebar.title("Music Data Analysis")
|
| 22 |
+
st.sidebar.markdown("[View Raw Data](data/music_data.csv)",
|
| 23 |
+
unsafe_allow_html=True)
|
| 24 |
+
|
| 25 |
analysis_option = st.sidebar.selectbox(
|
| 26 |
"Choose Analysis",
|
| 27 |
+
[
|
| 28 |
+
"Popularity Trends Over Time", "Audio Features Analysis", "Genre & Artist Analysis",
|
| 29 |
+
"Explicit Content Trends", "Album & Label Insights", "Tempo & Mood Analysis",
|
| 30 |
+
"Top Artists and Songs", "Album Release Trends", "Track Duration Analysis",
|
| 31 |
+
"Streaming and Engagement Insights", "Feature Comparisons Across Decades",
|
| 32 |
+
"Network Analysis"
|
| 33 |
+
]
|
| 34 |
)
|
| 35 |
|
| 36 |
st.sidebar.subheader("Filters")
|
|
|
|
| 43 |
"No data loaded or 'Decade' column missing. Check the 'data' folder.")
|
| 44 |
filtered_df = pd.DataFrame()
|
| 45 |
|
| 46 |
+
# Main Content
|
| 47 |
st.title("Music Data Analysis Dashboard")
|
| 48 |
st.markdown("Explore trends and insights from a diverse music dataset.")
|
| 49 |
|
| 50 |
+
if not df.empty:
|
| 51 |
+
st.write("### Raw Data Sample")
|
| 52 |
+
st.dataframe(df.head())
|
| 53 |
+
else:
|
| 54 |
+
st.error("Failed to load raw data. Check the 'data/music_data.csv' file.")
|
| 55 |
+
|
| 56 |
+
# Call Analysis Functions Based on Selection
|
| 57 |
if analysis_option == "Popularity Trends Over Time":
|
| 58 |
generate_popularity_trends(filtered_df)
|
| 59 |
elif analysis_option == "Audio Features Analysis":
|
|
|
|
| 78 |
generate_feature_comparisons(filtered_df)
|
| 79 |
elif analysis_option == "Network Analysis":
|
| 80 |
generate_network_analysis(filtered_df)
|
|
|
|
|
|
models/__pycache__/data_processor.cpython-310.pyc
CHANGED
|
Binary files a/models/__pycache__/data_processor.cpython-310.pyc and b/models/__pycache__/data_processor.cpython-310.pyc differ
|
|
|
models/data_processor.py
CHANGED
|
@@ -4,7 +4,7 @@ import streamlit as st
|
|
| 4 |
def load_data():
|
| 5 |
try:
|
| 6 |
df = pd.read_csv('data/music_data.csv', on_bad_lines='skip')
|
| 7 |
-
st.write("**Raw Data Sample:**", df.head())
|
| 8 |
except FileNotFoundError:
|
| 9 |
st.error("Error: 'data/music_data.csv' not found. Please ensure the file exists.")
|
| 10 |
return pd.DataFrame()
|
|
|
|
| 4 |
def load_data():
|
| 5 |
try:
|
| 6 |
df = pd.read_csv('data/music_data.csv', on_bad_lines='skip')
|
| 7 |
+
st.write("**Raw Data Sample:**", df.head())
|
| 8 |
except FileNotFoundError:
|
| 9 |
st.error("Error: 'data/music_data.csv' not found. Please ensure the file exists.")
|
| 10 |
return pd.DataFrame()
|