{"id":21322389,"url":"https://github.com/aroramrinaal/spotistats","last_synced_at":"2025-03-15T23:12:57.718Z","repository":{"id":240332477,"uuid":"802344722","full_name":"aroramrinaal/Spotistats","owner":"aroramrinaal","description":"Spotistats is a data analysis and visualization project based on your Spotify streaming history.","archived":false,"fork":false,"pushed_at":"2024-05-22T17:42:32.000Z","size":5673,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-22T17:42:48.706Z","etag":null,"topics":["data-analysis","numbers","spotify","spotify-history","visualization"],"latest_commit_sha":null,"homepage":"","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/aroramrinaal.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-05-18T03:37:44.000Z","updated_at":"2024-05-22T17:42:34.000Z","dependencies_parsed_at":"2024-05-22T17:54:06.929Z","dependency_job_id":null,"html_url":"https://github.com/aroramrinaal/Spotistats","commit_stats":null,"previous_names":["aroramrinaal/spotistats"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aroramrinaal%2FSpotistats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aroramrinaal%2FSpotistats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aroramrinaal%2FSpotistats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aroramrinaal%2FSpotistats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aroramrinaal","download_url":"https://codeload.github.com/aroramrinaal/Spotistats/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243801681,"owners_count":20350108,"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":["data-analysis","numbers","spotify","spotify-history","visualization"],"created_at":"2024-11-21T20:14:58.506Z","updated_at":"2025-03-15T23:12:57.693Z","avatar_url":"https://github.com/aroramrinaal.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spotistats\n\nSpotistats is a data analysis and visualization project based on personal Spotify streaming history. Spotify is one of the most famous and popular music streaming platforms. This project aims to explore and analyze the user's Spotify usage to gain useful insights into their listening habits.\n\nIn this project, we will explore various aspects of Spotify usage data, including:\n- The list of songs played\n- The list of artists of the songs\n- The duration of usage and more\n\nThe dataset used here showcases the personal usage of Spotify, downloaded from Spotify's Privacy Setting section, which allows anyone to download their personal usage data.\n\n\u003cimg width=\"809\" alt=\"Screenshot 2024-05-22 at 10 26 29\" src=\"https://github.com/aroramrinaal/Spotistats/assets/90490253/75eef9ea-a147-49f7-b0f4-b74ca50ef0d2\"\u003e\n\nFor this Exploratory Data Analysis (EDA) project, we will utilize several tools and libraries:\n- **Jupyter Notebook**: An open-source web application that allows you to create and share documents that contain live code, equations, visualizations, and narrative text.\n- **Python**: A powerful programming language known for its readability and vast library support.\n- **Libraries**:\n  - `numpy`: A library for numerical computations.\n  - `pandas`: A powerful data manipulation and analysis library.\n  - `matplotlib`: A plotting library for creating static, animated, and interactive visualizations.\n  - `seaborn`: A statistical data visualization library based on matplotlib.\n  - `wordcloud`: A library for generating word clouds from text.\n\n## Contents of the .zip File\n\nWhen you download your Spotify extended streaming history, you will receive a .zip file. After extracting the .zip file, the folder structure will look like this:\n\n\u003cimg width=\"783\" alt=\"Screenshot 2024-05-17 at 06 59 13\" src=\"https://github.com/aroramrinaal/Spotistats/assets/90490253/a85d5e44-e9ff-4893-a535-c52058233632\"\u003e\n\n## Top 10 Favorite Artists\n\nIn this project, we analyze and visualize the top 10 favorite artists based on listening time (hours) and the number of times songs were played (count).\n\n### Visualization of Top 10 Favorite Artists by Listening Time (Hours)\n\n```python\n# Group by artist name and calculate the sum of listening time and counts\ntop_artists_df = spotify_stream_df.groupby(\"master_metadata_album_artist_name\")[[\"Listening Time (Hours)\", \"Count\"]].sum()\n\n# Sort artists by Listening Time (Hours) and select the top 10\ntop_10_artists_hours = top_artists_df.sort_values(by=\"Listening Time (Hours)\", ascending=False).head(10)\n\n# Visualization of top 10 unique artists by listening time (hours)\nplt.figure(figsize=(12, 8))\nsns.barplot(x=top_10_artists_hours.index, y=top_10_artists_hours[\"Listening Time (Hours)\"], palette='viridis')\nplt.xlabel('Artists')\nplt.ylabel('No. of Hours Songs Played')\nplt.title('My Top 10 Favourite Artist (based on Hours)')\nplt.xticks(rotation=45, ha='right')\nplt.show()\n```\n![output](https://github.com/aroramrinaal/Spotistats/assets/90490253/751484f1-8ebb-45ed-8012-ec0822b972c5)\n\n### Visualization of Top 10 Favorite Artists by Listening Count\n\n```python\n# Top 10 artists by Count\ntop_10_artists_count = top_artists_df.sort_values(by=\"Count\", ascending=False).head(10)\n\n# Visualization of top 10 unique artists by play count\nplt.figure(figsize=(10, 5))\nsns.barplot(x=top_10_artists_count.index, y=top_10_artists_count[\"Count\"], palette='magma')\nplt.xlabel('Artists')\nplt.ylabel('No. of Times Songs Played')\nplt.title('My Top 10 Favourite Artist (based on Counts)')\nplt.xticks(rotation=45, ha='right')\nplt.show()\n```\n![output](https://github.com/aroramrinaal/Spotistats/assets/90490253/8bfbbe18-4703-4935-bdf6-423fb0885464)\n\n## Percentage of Unique Tracks\n\nIn this project, we analyze the percentage of unique tracks in the listening history and visualize it using a pie chart.\n\n### Visualization of Unique Tracks Percentage\n\n```python\n# Calculate the number of unique tracks\nunique_tracks = spotify_stream_df[\"master_metadata_track_name\"].nunique()\n\n# Calculating the total number of track entries\ntotal_tracks = spotify_stream_df[\"master_metadata_track_name\"].count()\n\n# Calculate the percentage of unique tracks\nunique_tracks_percentage = (unique_tracks / total_tracks) * 100\n\n# Prepare data for the pie chart\nunique_tracks_list = np.array([unique_tracks, total_tracks - unique_tracks])\nunique_tracks_list_labels = [\"Unique Tracks\", \"Non Unique Tracks\"]\n\n# Create a pie chart\nfig, ax = plt.subplots(figsize=(12, 6))\nax.pie(unique_tracks_list, labels=unique_tracks_list_labels, autopct='%1.1f%%', explode=[0.05, 0.05], startangle=180, shadow=True)\nplt.title(\"Unique Tracks Percentage\")\nplt.show()\n\n# Print the calculated percentages for reference\nprint(f\"Number of unique tracks: {unique_tracks}\")\nprint(f\"Total number of track entries: {total_tracks}\")\nprint(f\"Percentage of unique tracks: {unique_tracks_percentage:.2f}%\")\n```\n![5114962f-031d-46b3-ade1-5080e609aed5](https://github.com/aroramrinaal/Spotistats/assets/90490253/2deeeea6-59e9-4b49-ad16-2e695d8449e0)\n\n## Day Wise Percentage of Spotify Streaming\n\nIn this project, we analyze the distribution of Spotify streaming activity across different days of the week and visualize it using a pie chart.\n\n### Visualization of Day Wise Percentage of Spotify Streaming\n\n```python\nfig, ax = plt.subplots(figsize=(12, 6))\nax.pie(spotify_stream_df[\"day-name\"].value_counts(), labels=spotify_stream_df[\"day-name\"].value_counts().index, autopct='%1.1f%%', startangle=180, shadow=True)\nax.set(title=\"Day wise % of Spotify Streaming\")\nplt.show()\n```\n![3515fe61-a713-4a95-b79b-f0543643be2f](https://github.com/aroramrinaal/Spotistats/assets/90490253/b99d87a3-9594-47a1-9a9b-89de13db8667)\n\n## Average Usage Over a Day\n\nIn this project, we analyze the distribution of Spotify streaming activity over the hours of a day and visualize it using a histogram with a kernel density estimate (KDE).\n\n### Visualization of Average Distribution of Streaming Over Day Hours\n\n```python\n# Average Usage over a day\nfig, ax = plt.subplots(figsize=(12,8))\nax.set(title=\"Average Distribution of Streaming Over Day Hours\", xlabel=\"Hours (in 24 hour format)\", ylabel=\"Songs Played\")\nsns.histplot(spotify_stream_df[\"hours\"], bins=24, kde=True, color=\"darkgreen\")\nplt.show()\n```\n![97a4b2fb-5254-4559-be90-25d065ba7e54](https://github.com/aroramrinaal/Spotistats/assets/90490253/7c31fe2b-5de7-4abe-aadf-b6f7979f973e)\n\n## Top 100 Favorite Artists\n\nIn this project, we generate a word cloud to visualize the top 100 favorite artists based on the number of times their songs were played.\n\n### Visualization of Top 100 Favorite Artists\n\n```python\n# Sort artists by Count\ntop_artists_df = top_artists_df.sort_values(by='Count', ascending=False)\n\n# Select the top 100 artists\ntop_100_artists = top_artists_df.head(100)\n\n# Generate the word cloud\nwordcloud = WordCloud(width=800, height=400, background_color='white').generate_from_frequencies(top_100_artists['Count'])\n\n# Display the word cloud\nplt.figure(figsize=(14, 5))\nplt.imshow(wordcloud, interpolation='bilinear')\nplt.axis('off')\nplt.title('Top 100 Favorite Artists')\nplt.show()\n```\n![edcf03df-1f5b-43e8-83ea-2ae145d74023](https://github.com/aroramrinaal/Spotistats/assets/90490253/05853e3b-79f4-4041-9cb0-96d52b1b877c)\n\n## Active Usage in a Day Over a Week\n\nIn this project, we analyze the active usage of Spotify over different hours of the day throughout the week and visualize it using a heatmap.\n\n### Visualization of Active Usage in a Day Over a Week\n\n```python\n# Extract day of the week and hour from 'Play-Time'\nspotify_stream_df['day_of_week'] = spotify_stream_df['Play-Time'].dt.day_name()\nspotify_stream_df['hour'] = spotify_stream_df['Play-Time'].dt.hour\n\n# Aggregate data by day of the week and hour\nusage_by_day_hour = spotify_stream_df.groupby(['day_of_week', 'hour']).size().unstack(fill_value=0)\n\n# Reorder the days of the week\ndays_order = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']\nusage_by_day_hour = usage_by_day_hour.reindex(days_order)\n\n# Create a heatmap\nplt.figure(figsize=(12, 8))\nsns.heatmap(usage_by_day_hour, cmap='Blues', annot=True, fmt='d', cbar_kws={'label': 'Number of Songs Played'})\nplt.title('Spotify Usage (Active Usage in a Day Over a Week)')\nplt.xlabel('Hour of Day')\nplt.ylabel('Day of Week')\nplt.show()\n```\n![203d4346-7dbf-4134-a961-30272869c7ed](https://github.com/aroramrinaal/Spotistats/assets/90490253/f873f1ae-d860-4c85-98eb-fe8c7cc1139d)\n\n## Number of Songs Played Each Day\n\nIn this project, we analyze the number of songs played each day and visualize it using a scatter plot.\n\n### Visualization of Number of Songs Played Each Day\n\n```python\n# Aggregate data by date\nsongs_per_day = spotify_stream_df.groupby(spotify_stream_df['Play-Time'].dt.date)['Count'].sum().reset_index()\nsongs_per_day.columns = ['Date', 'Number of Songs Played']\n\n# Identify the day with maximum songs played\nmax_songs_day = songs_per_day[songs_per_day['Number of Songs Played'] == songs_per_day['Number of Songs Played'].max()]\n\nprint(f\"The day with the maximum number of songs played is: {max_songs_day['Date'].values[0]} with {max_songs_day['Number of Songs Played'].values[0]} songs.\")\n\n# Plot a scatter plot to show all the dates\nplt.figure(figsize=(12, 7))\nsns.scatterplot(data=songs_per_day, x='Date', y='Number of Songs Played', hue='Number of Songs Played', palette='viridis', legend=None)\nplt.title('Number of Songs Played Each Day')\nplt.xlabel('Date')\nplt.ylabel('Number of Songs Played')\nplt.xticks(rotation=45)\nplt.grid(True)\nplt.show()\n```\n![f57e95e6-b85a-425e-944e-91c325683d58](https://github.com/aroramrinaal/Spotistats/assets/90490253/13c57a4b-06e8-4576-95b6-c98bea1f0dc9)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faroramrinaal%2Fspotistats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faroramrinaal%2Fspotistats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faroramrinaal%2Fspotistats/lists"}