Spaces:
Sleeping
Sleeping
File size: 4,345 Bytes
6ce9997 97fec97 873154b 10d82a8 6ce9997 10d82a8 6ce9997 10d82a8 985869f 06b27c8 985869f 6ce9997 10d82a8 6ce9997 97fec97 10d82a8 985869f 10d82a8 985869f 10d82a8 873154b 985869f 873154b 6ce9997 10d82a8 b595166 10d82a8 873154b 10d82a8 873154b 10d82a8 873154b 10d82a8 873154b 10d82a8 873154b 10d82a8 873154b 10d82a8 873154b 10d82a8 873154b 10d82a8 873154b 10d82a8 873154b 10d82a8 873154b 10d82a8 873154b 10d82a8 873154b 985869f |
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 |
import os
import pandas as pd
import streamlit as st
from models.data_processor import load_data
from functions.visualizations import (
generate_popularity_trends, generate_audio_features, generate_genre_analysis,
generate_explicit_trends, generate_album_insights, generate_tempo_mood,
generate_top_artists_songs, generate_album_release_trends, generate_duration_analysis,
generate_streaming_insights, generate_feature_comparisons, generate_network_analysis
)
# Load Data
df = load_data()
# Sidebar - Add Spotify Logo from URL centered at the top
st.sidebar.markdown("<div style='display: flex; justify-content: center; align-items: center; padding: 10px 0;'>", unsafe_allow_html=True)
st.sidebar.markdown(
"""
<div style='display: flex; justify-content: center; align-items: center; padding: 20px 0;'>
<img src='https://upload.wikimedia.org/wikipedia/commons/1/19/Spotify_logo_without_text.svg' width='150' alt='Spotify Logo'>
</div>
""",
unsafe_allow_html=True
)
st.sidebar.markdown("</div>", unsafe_allow_html=True)
# Sidebar - Title & Filters
st.sidebar.title("Music Data Analysis")
analysis_option = st.sidebar.selectbox(
"Choose Analysis",
[
"Popularity Trends Over Time", "Audio Features Analysis", "Genre & Artist Analysis",
"Explicit Content Trends", "Album & Label Insights", "Tempo & Mood Analysis",
"Top Artists and Songs", "Album Release Trends", "Track Duration Analysis",
"Streaming and Engagement Insights", "Feature Comparisons Across Decades",
"Network Analysis"
]
)
st.sidebar.subheader("Filters")
if not df.empty and 'Decade' in df.columns:
decades = st.sidebar.multiselect("Select Decades", sorted(df['Decade'].unique()), default=sorted(df['Decade'].unique()))
filtered_df = df[df['Decade'].isin(decades)] if decades else df
else:
st.sidebar.warning("No data loaded or 'Decade' column missing. Check the 'data' folder.")
filtered_df = pd.DataFrame()
# Add View Raw Data link at the bottom of the sidebar
st.sidebar.markdown("[View Raw Data Source](https://www.kaggle.com/datasets/joebeachcapital/top-10000-spotify-songs-1960-now)", unsafe_allow_html=True)
# Main Content
st.title("Music Data Analysis Dashboard")
# st.markdown("Explore trends and insights from a diverse music dataset.")
# Call Analysis Functions Based on Selection with updated explanations
if analysis_option == "Popularity Trends Over Time":
st.markdown("**Popularity Trends:** Tracks popularity changes over time.")
generate_popularity_trends(filtered_df)
elif analysis_option == "Audio Features Analysis":
st.markdown("**Audio Features:** Shows feature distributions.")
generate_audio_features(filtered_df)
elif analysis_option == "Genre & Artist Analysis":
st.markdown("**Genre & Artist:** Highlights top genres.")
generate_genre_analysis(filtered_df)
elif analysis_option == "Explicit Content Trends":
st.markdown("**Explicit Trends:** Compares explicit songs.")
generate_explicit_trends(filtered_df)
elif analysis_option == "Album & Label Insights":
st.markdown("**Album & Label:** Displays top labels.")
generate_album_insights(filtered_df)
elif analysis_option == "Tempo & Mood Analysis":
st.markdown("**Tempo & Mood:** Tracks tempo trends.")
generate_tempo_mood(filtered_df)
elif analysis_option == "Top Artists and Songs":
st.markdown("**Top Artists/Songs:** Lists top artists and songs.")
generate_top_artists_songs(filtered_df)
elif analysis_option == "Album Release Trends":
st.markdown("**Album Trends:** Shows release patterns.")
generate_album_release_trends(filtered_df)
elif analysis_option == "Track Duration Analysis":
st.markdown("**Duration Analysis:** Displays track durations.")
generate_duration_analysis(filtered_df)
elif analysis_option == "Streaming and Engagement Insights":
st.markdown("**Streaming Insights:** Explores engagement trends.")
generate_streaming_insights(filtered_df)
elif analysis_option == "Feature Comparisons Across Decades":
st.markdown("**Feature Comparisons:** Compares features across decades.")
generate_feature_comparisons(filtered_df)
elif analysis_option == "Network Analysis":
st.markdown("**Network Analysis:** Visualizes artist connections.")
generate_network_analysis(filtered_df) |