{"id":22353975,"url":"https://github.com/ckyle30/spotify-eda-deguzman-2ecea","last_synced_at":"2025-03-26T12:28:29.524Z","repository":{"id":275145535,"uuid":"885093820","full_name":"Ckyle30/Spotify-EDA-DEGUZMAN-2ECEA","owner":"Ckyle30","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-08T11:05:01.000Z","size":971,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T13:43:41.334Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ckyle30.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-08T00:12:19.000Z","updated_at":"2024-11-08T11:05:04.000Z","dependencies_parsed_at":"2025-01-31T13:43:44.774Z","dependency_job_id":"b663d1bd-4b76-4c74-b75d-a59a8b5026c9","html_url":"https://github.com/Ckyle30/Spotify-EDA-DEGUZMAN-2ECEA","commit_stats":null,"previous_names":["ckyle30/spotify-eda-deguzman-2ecea"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ckyle30%2FSpotify-EDA-DEGUZMAN-2ECEA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ckyle30%2FSpotify-EDA-DEGUZMAN-2ECEA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ckyle30%2FSpotify-EDA-DEGUZMAN-2ECEA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ckyle30%2FSpotify-EDA-DEGUZMAN-2ECEA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ckyle30","download_url":"https://codeload.github.com/Ckyle30/Spotify-EDA-DEGUZMAN-2ECEA/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245652977,"owners_count":20650607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-04T13:10:38.858Z","updated_at":"2025-03-26T12:28:29.516Z","avatar_url":"https://github.com/Ckyle30.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🎶Exploratory Data Analysis on Spotify 2023 Dataset🎵\n\n##  Introduction\n\nThis project delivers a comprehensive exploratory data analysis (EDA) of the **Top Spotify Songs of 2023** dataset, highlighting streaming trends, popular patterns, and insights within contemporary music. Utilizing Python and powerful data visualization tools, this analysis delves into the unique features of highly streamed tracks, artist trajectories, and genre representation to shed light on the elements driving this year's biggest streaming hits. Within this repository, you’ll find the complete code, visualizations, and findings essential for grasping the evolving trends in music streaming.\n\n\u003e **Note:**  \n\u003e 💡 This analysis was conducted on the dataset provided on [Kaggle](https://www.kaggle.com/datasets/nelgiriyewithana/top-spotify-songs-2023). Feel free to download the dataset via the linked text for reference.\n##  Dataset Overview\n Libraries that are important for data analysis and visualization\n\n ```python\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n```\nThe downloaded CSV file for data analysis is loaded into the spotify variable.\n```python\n# Load the data\nspotify = pd.read_csv('spotify-2023.csv')\nspotify\n```\n![image](https://github.com/user-attachments/assets/078f6a03-5074-4a53-88e8-7290bd7d729d)\nThe dataframe above lists the top 953 songs on Spotify, containing 24 columns.\n\nInput:\n```python\nprint(f\"Dataset Dimensions:\\nRows: {spotify.shape[0]}, Columns: {spotify.shape[1]}\")\nspotify.info()\n\nmissing_values = spotify.isnull().sum()\nmissing_values = missing_values[missing_values \u003e 0].reset_index()\nmissing_values.columns = ['Column', 'Missing Values']\nmissing_values\n```\nOutput:\n\n![image](https://github.com/user-attachments/assets/9c5ac1fe-0077-44b6-8d49-d964c64f771c)\n\nThis display the dataset dimensions, basic information and missing values.\n\nInput:\n```python\nprint(f\"Rows: {spotify.shape[0]} \\nColumns: {spotify.shape[1]}\")\n```\nDisplaying the rows and column of the dataset for better understanding, cleaning, and analyzation of the dataset\n\n## General Statistics \nIn this section, we will tackle about the mean,median, and standard deviation of strems, and the distribution of \"released_year\" and \"artist_count\", also the noticeable trends or outliers.\n```python\nspotify.describe()\n```\nBy using .describe() we can get the general statistic of the dataset\n![image](https://github.com/user-attachments/assets/fa06c161-9578-4afd-a6cf-df07930844b7)\n![image](https://github.com/user-attachments/assets/3fd8950a-d567-47b7-857a-f470ecde4504)\n\nInput:\n```python\nspotify['streams'] = pd.to_numeric(spotify['streams'].astype(str).str.replace(',', ''), errors='coerce')\n\nmean_streams = spotify['streams'].mean()\nmedian_streams = spotify['streams'].median()\nstd_streams = spotify['streams'].std()\n\nstream_stats = pd.DataFrame({\n    'Statistic': ['Mean', 'Median', 'Standard Deviation'],\n    'Value': [mean_streams, median_streams, std_streams]\n})\nstream_stats.style.format({\"Value\": \"{:.2f}\"})\n```\nOutput:\n\n![image](https://github.com/user-attachments/assets/650316ec-be1e-4398-8027-63b8395209d5)\n\nStatistic for streams are shown above.\n## Released Year and Artist Count\n### Release Year\nInput:\n```python\n# Distribution of release years\nyear_counts = spotify['released_year'].value_counts().sort_index()\n\n# Plot distribution with rotated x-axis labels for better readability\nplt.figure(figsize=(10, 5))\nsns.barplot(x=year_counts.index, y=year_counts.values, color='lightblue')\nplt.title('Tracks by Release Year')\nplt.xlabel('Year')\nplt.ylabel('Number of Tracks')\nplt.xticks(rotation=90)  # Rotate x-axis labels vertically\nplt.tight_layout()\nplt.show()\n\n```\nOutput:\n![image](https://github.com/user-attachments/assets/f9e13d55-bcd0-4c89-90aa-12d2c1116ccd)\nThe data shows a notable surge in track releases in 2022, suggesting that this year had the highest volume of significant music releases. Furthermore, an upward trend in popular music is observed starting from 2014, signaling the beginning of an increase in popular tracks and emerging musical trends.\n\n### Artist Count\ninput:\n```python\n# Set Seaborn style and create a simplified artist count distribution plot\nplt.figure(figsize=(8, 5))\nsns.histplot(spotify['artist_count'], binwidth=1, color=\"coral\", edgecolor=\"black\")\nplt.title(\"Distribution of Tracks by Artist Count\", fontsize=14)\nplt.xlabel(\"Number of Artists\", fontsize=12)\nplt.ylabel(\"Number of Tracks\", fontsize=12)\nplt.grid(axis='y', linestyle='--', alpha=0.7)\nplt.tight_layout()\nplt.show()\n```\nOutput:\n![image](https://github.com/user-attachments/assets/eb4a1793-29c9-480a-a688-807e8503b428)\nThe data indicates that most of the released tracks are solo productions, though a significant portion also includes collaborations with other artists.\n\n## Top Performers\nIn this section, we split it in to 2 parts. The top 5 most streamed tracks, and The top 5 most frequent artist.\n### Top 5 Most Streamed Tracks\nInput:\n```python\nspotify['streams'] = pd.to_numeric(spotify['streams'].astype(str).str.replace(',', ''), errors='coerce')\ntop_5_streams_df = spotify.sort_values(by='streams', ascending=False).head(5).reset_index(drop=True)\ntop_5_streams_df\n```\nOutput:\n![image](https://github.com/user-attachments/assets/c6e24775-c551-44a4-aecb-08410b14553d)\nThis shows that Blinding Lights by the Weeknd is the most streamed tracks in 2023\n### Top 5 Most Frequent \nInput:\n```python\ntop_artists = spotify['artist(s)_name'].str.split(', ').explode().value_counts().nlargest(5).reset_index()\ntop_artists.columns = ['Artist', 'Track Count']\ntop_artists\n```\nOutput:\n\n![image](https://github.com/user-attachments/assets/fd098be7-fe54-494d-8410-65ce16452913)\n\nThe leading artist during 2023 was Bad Bunny having 40 tracks in the spotify list\n\n## Temporal Trends\nIn this section, we analyze the trends in the number of tracks released over time, and if the number of tracks released per month follow any noticable patterns.\nInput:\n```python\n# Trend: Number of tracks released per year\n# Tracks released per year with vertical bar chart and rotated x-axis labels\nplt.figure(figsize=(12, 6))\nsns.barplot(x=tracks_per_year.index, y=tracks_per_year.values, color='teal')\nplt.title('Number of Tracks Released Per Year', fontsize=14)\nplt.xlabel('Year', fontsize=12)\nplt.ylabel('Number of Tracks', fontsize=12)\nplt.xticks(rotation=45, ha='right')  # Rotate labels for readability\nplt.grid(axis='y', linestyle='--', alpha=0.7)\nplt.tight_layout()\nplt.show()\n\n\n# Trend: Tracks released by month\nspotify['released_month'] = pd.to_numeric(spotify['released_month'], errors='coerce')\ntracks_per_month = spotify['released_month'].value_counts().sort_index()\n\nplt.figure(figsize=(10, 5))\nsns.barplot(x=range(1, 13), y=tracks_per_month, color='skyblue')\nplt.title('Tracks Released by Month')\nplt.xlabel('Month')\nplt.ylabel('Number of Tracks')\nplt.xticks(ticks=range(12), labels=['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'])\nplt.show()\n```\nOutput:\n![image](https://github.com/user-attachments/assets/36cc920c-9055-4fe2-8534-0c50f62484d4)\n![image](https://github.com/user-attachments/assets/dc1e74dc-b024-4816-a0cf-269d7833ec06)\nAccording to the yearly graph, 2022 stands out as a pivotal year, showing a substantial increase in the number of popular tracks released. Meanwhile, the monthly graph reveals a notable spike in popular music releases during January and May, indicating that these months see a peak in track popularity.\n\n## Genre and Music Characteristics\nIn this section, we examine the connection between music genres and their defining characteristics, such as danceability, valence, energy, BPM, and acousticness. By investigating how these attributes differ across genres, we aim to identify trends and preferences that contribute to streaming success and influence listener choices on Spotify.\n### Streams and Attribute Correlation\nInput:\n```python\n# Average musical attributes by release year\nattributes_by_year = spotify.groupby('released_year')[['danceability_%', 'energy_%', 'acousticness_%', 'valence_%']].mean()\n\n# FacetGrid for individual attribute trends over time\nsns.set(style=\"whitegrid\")\nattributes_by_year_melted = attributes_by_year.reset_index().melt(id_vars='released_year', var_name='Attribute', value_name='Average Value')\n\ng = sns.FacetGrid(attributes_by_year_melted, col=\"Attribute\", col_wrap=2, height=4, sharey=False)\ng.map(sns.lineplot, 'released_year', 'Average Value', color='teal', marker='o')\n\ng.set_axis_labels(\"Year\", \"Average Value (%)\")\ng.set_titles(\"{col_name}\")\ng.add_legend()\nplt.suptitle(\"Yearly Trends of Musical Attributes\", y=1.02, fontsize=16, fontweight='bold')\nplt.show()\n```\nOutput:\n![image](https://github.com/user-attachments/assets/bb52d11d-75fe-4fda-bcaa-7b62caa4c855)\nIn the FacetGrid analysis, most attributes show a negative correlation with streams, suggesting that these characteristics do not strongly influence track popularity. This could be due to the varying preferences among different listener\n\n### Correlation of Streams and Musical Attributes\nInput:\n```python\n# Set up the figure for subplots\nfig, axes = plt.subplots(1, 4, figsize=(24, 6))\n\n# Scatter plot for Streams vs Danceability\nsns.scatterplot(ax=axes[0], x='danceability_%', y='streams', data=spotify, s=100, color='skyblue', edgecolor='black')\naxes[0].set_title(\"Streams vs Danceability %\", fontsize=14)\naxes[0].set_xlabel(\"Danceability (%)\", fontsize=12)\naxes[0].set_ylabel(\"Streams\", fontsize=12)\n\n# Scatter plot for Streams vs BPM\nsns.scatterplot(ax=axes[1], x='bpm', y='streams', data=spotify, s=100, color='lightgreen', edgecolor='black')\naxes[1].set_title(\"Streams vs BPM\", fontsize=14)\naxes[1].set_xlabel(\"BPM\", fontsize=12)\naxes[1].set_ylabel(\"Streams\", fontsize=12)\n\n# Scatter plot for Streams vs Energy\nsns.scatterplot(ax=axes[2], x='energy_%', y='streams', data=spotify, s=100, color='orange', edgecolor='black')\naxes[2].set_title(\"Streams vs Energy %\", fontsize=14)\naxes[2].set_xlabel(\"Energy (%)\", fontsize=12)\naxes[2].set_ylabel(\"Streams\", fontsize=12)\n\n# Scatter plot for Streams vs Valence\nsns.scatterplot(ax=axes[3], x='valence_%', y='streams', data=spotify, s=100, color='salmon', edgecolor='black')\naxes[3].set_title(\"Streams vs Valence %\", fontsize=14)\naxes[3].set_xlabel(\"Valence (%)\", fontsize=12)\naxes[3].set_ylabel(\"Streams\", fontsize=12)\n\n# Adjust layout for better spacing\nplt.tight_layout()\n\n# Show the plot\nplt.show()\n```\nOutput:\n![image](https://github.com/user-attachments/assets/7edbf545-a0e7-4c71-a9d9-70de9e0f83a1)\nThe scatterplot analysis revealed no significant correlation between the different music attributes and the number of streams. This finding led to the realization that the characteristics of a song may not necessarily determine its popularity.\n\n### Attributes Correlation\nInput:\n```python\n# Set up the figure for subplots\nfig, axes = plt.subplots(1, 2, figsize=(14, 6))\n\n# Scatter plot for Danceability vs Energy\nsns.scatterplot(ax=axes[0], x='danceability_%', y='energy_%', data=spotify, s=100, color='dodgerblue', edgecolor='black')\naxes[0].set_title(\"Danceability % vs Energy %\", fontsize=14)\naxes[0].set_xlabel(\"Danceability (%)\", fontsize=12)\naxes[0].set_ylabel(\"Energy (%)\", fontsize=12)\n\n# Scatter plot for Valence vs Acousticness\nsns.scatterplot(ax=axes[1], x='valence_%', y='acousticness_%', data=spotify, s=100, color='darkorange', edgecolor='black')\naxes[1].set_title(\"Valence % vs Acousticness %\", fontsize=14)\naxes[1].set_xlabel(\"Valence (%)\", fontsize=12)\naxes[1].set_ylabel(\"Acousticness (%)\", fontsize=12)\n\n# Adjust layout to prevent overlapping\nplt.tight_layout()\n\n# Show the plot\nplt.show()\n```\nOutput:\n![image](https://github.com/user-attachments/assets/ad09a945-84c9-449b-b2d9-99018091b292)\nA strong correlation was observed between danceability and energy, indicating that as the danceability of a track increases, so does its energy level, and vice versa. On the other hand, valence and acousticness showed almost no correlation, suggesting that these two attributes are independent of each other.\n\n## Platform Popularity\nIn this section, we will explore the popularity and performance of different music streaming platform.\nInput:\n```python\n# Platform popularity\nplatform_cols = ['in_spotify_playlists', 'in_apple_playlists', 'in_deezer_playlists']\nspotify[platform_cols] = spotify[platform_cols].apply(pd.to_numeric, errors='coerce')\nplatform_data = spotify[platform_cols].sum().reset_index()\nplatform_data.columns = ['Platform', 'Count']\nplatform_data.style.set_caption(\"Popularity of Tracks Across Platforms\")\n\n# Plotting platform popularity\nplt.figure(figsize=(10, 6))\nsns.barplot(data=platform_data, x='Platform', y='Count')\nplt.title('Popularity of Tracks Across Platforms')\nplt.xlabel('Platform')\nplt.ylabel('Number of Tracks')\nplt.show()\n```\nOutput:\n![image](https://github.com/user-attachments/assets/fe510ec1-94b1-4ad0-a2d3-a4988481908d)\nThe bar graph indicates that Spotify playlists feature the most popular songs among all platforms, highlighting Spotify's prominence in the music streaming space.\n## Advance Analysis\nIn this section, we will identify the patterns among tracks with the same key or mode, and identifying if a certain genre or artist consistently appear in more playlist or charts.\n### Key Distribution\nInput:\n```python\n# Distribution by key and mode\nkey_mode_counts = spotify.groupby(['key', 'mode']).size().reset_index(name='Count')\n\nplt.figure(figsize=(12, 6))\nsns.barplot(data=key_mode_counts, x='key', y='Count', hue='mode', palette='coolwarm')\nplt.title('Distribution of Tracks by Key and Mode')\nplt.xlabel('Key')\nplt.ylabel('Number of Tracks')\nplt.legend(title='Mode')\nplt.show()\n```\nOutput:\n![image](https://github.com/user-attachments/assets/f54160c1-324b-48e6-a292-da699c5b8f9e)\nThe bar graph shows that C# has the highest number of tracks, whether in a minor or major key, while D# is the least used minor key and A is the least used major key.\n### Top 10 Most Frequent Artist in Charts\nInput:\n```python\n# Popular artists in playlists and charts\nplatform_columns = ['in_spotify_playlists', 'in_spotify_charts', 'in_apple_playlists', 'in_apple_charts', 'in_deezer_playlists', 'in_deezer_charts']\nartist_counts = spotify.groupby(\"artist(s)_name\")[platform_columns].sum().sum(axis=1).sort_values(ascending=False)\ntop_10_artists = artist_counts.head(10).reset_index()\ntop_10_artists.columns = ['Artist', 'Appearances']\n\n# Display top 10 most frequently appearing artists in playlists and charts\ntop_10_artists.style.set_caption(\"Top 10 Artists in Playlists/Charts\")\n\n# Plotting top artists\nplt.figure(figsize=(14, 7))\nsns.barplot(data=top_10_artists, x='Appearances', y='Artist', hue='Artist', palette='coolwarm')\nplt.title('Top 10 Artists in Playlists/Charts')\nplt.xlabel('Appearances')\nplt.ylabel('Artist')\nplt.show()\n```\nOutput:\n![image](https://github.com/user-attachments/assets/61073fa2-5ae0-4b5d-bcd1-de309f409553)\n\nThe top three artists most frequently appearing in playlists and charts are The Weeknd, Taylor Swift, and Ed Sheeran, known for their pop, romance, and R\u0026B songs, respectively.\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fckyle30%2Fspotify-eda-deguzman-2ecea","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fckyle30%2Fspotify-eda-deguzman-2ecea","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fckyle30%2Fspotify-eda-deguzman-2ecea/lists"}