This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| full_grid(album_images, 'Album') | |
| full_grid(artist_images, 'Artist') | |
| mini_grid(album_images, 'Album') | |
| mini_grid(artist_images, 'Artist') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import requests | |
| import pandas as pd | |
| from PIL import Image | |
| # path for the excel file for your top albums | |
| top_albums = pd.read_excel('') | |
| # path for the excel file for your top artists | |
| top_artists = pd.read_excel('') | |
| # path for an empty folder named 'Album-Images' where the album images will be saved to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| track_artist_album_df['Artist Image URL'] = track_artist_album_df['Artist URI'].map(unique_artist_image_url_dict) | |
| merged_track_artist_album_url_df = pd.merge(cleaned_df, track_artist_album_df, on='Track URI', how='left') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| artist_uris = track_artist_album_df['Artist URI'] | |
| unique_artist_uris = list(set(artist_uris)) | |
| n_unique_artist_sublists = len(unique_artist_uris) // 50 + (len(unique_artist_uris) % 50 > 0) | |
| unique_artist_sublists = [unique_artist_uris[i * 50 : (i + 1) * 50] for i in range(n_unique_artist_sublists)] | |
| unique_artist_image_url_dict = {} | |
| start_time = time.time() | |
| for artist_list in unique_artist_sublists: | |
| params = {'ids': ','.join(artist_list)} | |
| response = requests.get('https://api.spotify.com/v1/artists?', headers=headers, params=params) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| track_artist_df['Duplicate URI'] = track_artist_df['URI'] | |
| groups = track_artist_df.groupby(['Track', 'Artist']) | |
| for group_name, group_df in groups: | |
| if len(group_df) > 1: | |
| unique_uris = group_df['URI'].unique() | |
| track_artist_df.loc[group_df.index, 'Duplicate URI'] = unique_uris[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cleaned_df = pd.DataFrame(list(zip( | |
| filtered_data['master_metadata_track_name'], | |
| filtered_data['master_metadata_album_album_name'], | |
| filtered_data['master_metadata_album_artist_name'], | |
| filtered_data['spotify_track_uri'])), | |
| columns=['Track', 'Album', 'Artist', 'Track URI'] | |
| ) | |
| cleaned_df = ( | |
| cleaned_df[~cleaned_df[['Track', 'Album', 'Artist', 'Track URI']] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| import time | |
| import spotipy | |
| import numpy as np | |
| import pandas as pd | |
| import seaborn as sns | |
| from sklearn import tree | |
| import spotipy.util as util | |
| from datetime import datetime | |
| import matplotlib.pyplot as plt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(png) | |
| library(grid) | |
| library(units) | |
| library(imager) | |
| library(readxl) | |
| library(ggplot2) | |
| # install.packages("ggimage") | |
| # source: https://www.nba.com/stats/teams/advanced?dir=A&sort=NET_RATING |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| spotifyArtistGrid = Image.new('RGB', (1000, 1000)) | |
| for i in range(1, 2): | |
| imagePath = imageFolderPath + '/artist_' + str(i) + '.png' | |
| artistImage = Image.open(imagePath) | |
| artistImage = artistImage.resize((400, 400)) | |
| spotifyArtistGrid.paste(artistImage, (300, 300)) | |
| for i in range(2, 6): | |
| imagePath = imageFolderPath + '/artist_' + str(i) + '.png' | |
| artistImage = Image.open(imagePath) | |
| artistImage = artistImage.resize((200, 200)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for image in range(len(artistImageUrlList)): | |
| artistImageUrl = requests.get(artistImageUrlList[image]) | |
| filename = 'artist_' + str(image+1) + '.png' | |
| with open(os.path.join(imageFolderPath, filename), 'wb') as out: | |
| out.write(artistImageUrl.content) |