Hey Listen... (Spotify Model)
This following exhibit deals primarily with a relational dataset - a small scale one.
You can click on the Spotify playlist below, which will then query the related sample list of 15 songs underneath.
You can click on the Spotify playlist below, which will then query the related sample list of 15 songs underneath.
(I am still messing with this one a bit. The bottom right quadrant was meant to show the song and other related music from YouTube, but I am not sure why the connection can't be stablished. Still looking into it!)
Unlike the Twitter exhibit, the dashboard above uses two data sources to create a playlists table and a song table. Spotify's API can either return a JSON file with the playlists or a list of songs with a single playlist but not both. So to get all this done, the following was coded:
Unlike the Twitter exhibit, the dashboard above uses two data sources to create a playlists table and a song table. Spotify's API can either return a JSON file with the playlists or a list of songs with a single playlist but not both. So to get all this done, the following was coded:
- Python provides the code language to create a script with an API authentication token request, which is then used to pull a JSON file from the Spotify API.
- The playlists JSON is first parsed with the pandas library to create a dataframe that is then exported to Google Sheets. Easy enough.
- The Python scripts then runs a second request that iterates each playlist in the created dataframe as an individual call.
- This Python iteration process has in itself a second iteration loop to add each song in each playlist to a 'master' list of songs.
- The pandas library then creates a second dataframe using the 'master' song list. and does a second export to Google Sheets.
- A problem here is that each playlist is presented as column rather than an individual cell next to the song; however, the pandas library has a cool method call .melt(). If you ever used Excel's Pivot table, then the .melt() method is the 'anti pivot table' since' it transposes columns into individual rows.
- When I first saw the .melt() method I thought 'why would you want to un-pivot anything?' turns out there is a good case to do so sometimes.
- Both the playlist and songs dataframes/tables are imported to Tableau.
- Tableau provides native relational tools within a visualization project. It's not as powerful as a standard SQL query, but it's a nifty tool for a small project like this.