{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "![Callysto.ca Banner](https://github.com/callysto/curriculum-notebooks/blob/master/callysto-notebook-banner-top.jpg?raw=true)\n", "\n", "\"Open" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Spotify Popularity\n", "\n", "Using [Spotify data](https://spotifycharts.com/regional) we can see which songs are the most popular.\n", "\n", "To look at just Canadian data, use the url `https://spotifycharts.com/regional/ca/daily/latest`" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PositionTrack NameArtistStreamsURL
01Mood (feat. Iann Dior)24kGoldn6261261https://open.spotify.com/track/3tjFYV6RSFtuktY...
12WAP (feat. Megan Thee Stallion)Cardi B6238079https://open.spotify.com/track/4Oun2ylbjFKMPTi...
23HawáiMaluma4934392https://open.spotify.com/track/1yoMvmasuxZfqHE...
34Holy (feat. Chance The Rapper)Justin Bieber4217945https://open.spotify.com/track/5u1n1kITHCxxp8t...
45Lemonade (feat. Gunna, Don Toliver & NAV)Internet Money4018915https://open.spotify.com/track/7hxHWCCAIIxFLCz...
..................
195196RITMO (Bad Boys For Life)Black Eyed Peas677270https://open.spotify.com/track/4NCsrTzgVfsDo8n...
196197AlaneRobin Schulz675869https://open.spotify.com/track/2u6Jm2klS4yvAlb...
197198Savage Remix (feat. Beyoncé)Megan Thee Stallion674390https://open.spotify.com/track/5v4GgrXPMghOnBB...
198199Mr. BrightsideThe Killers672452https://open.spotify.com/track/003vvx7Niy0yvhv...
199200Quero Você do Jeito Que QuiserMarília Mendonça671326https://open.spotify.com/track/64I6t2tuUGnIlaD...
\n", "

200 rows × 5 columns

\n", "
" ], "text/plain": [ " Position Track Name Artist \\\n", "0 1 Mood (feat. Iann Dior) 24kGoldn \n", "1 2 WAP (feat. Megan Thee Stallion) Cardi B \n", "2 3 Hawái Maluma \n", "3 4 Holy (feat. Chance The Rapper) Justin Bieber \n", "4 5 Lemonade (feat. Gunna, Don Toliver & NAV) Internet Money \n", ".. ... ... ... \n", "195 196 RITMO (Bad Boys For Life) Black Eyed Peas \n", "196 197 Alane Robin Schulz \n", "197 198 Savage Remix (feat. Beyoncé) Megan Thee Stallion \n", "198 199 Mr. Brightside The Killers \n", "199 200 Quero Você do Jeito Que Quiser Marília Mendonça \n", "\n", " Streams URL \n", "0 6261261 https://open.spotify.com/track/3tjFYV6RSFtuktY... \n", "1 6238079 https://open.spotify.com/track/4Oun2ylbjFKMPTi... \n", "2 4934392 https://open.spotify.com/track/1yoMvmasuxZfqHE... \n", "3 4217945 https://open.spotify.com/track/5u1n1kITHCxxp8t... \n", "4 4018915 https://open.spotify.com/track/7hxHWCCAIIxFLCz... \n", ".. ... ... \n", "195 677270 https://open.spotify.com/track/4NCsrTzgVfsDo8n... \n", "196 675869 https://open.spotify.com/track/2u6Jm2klS4yvAlb... \n", "197 674390 https://open.spotify.com/track/5v4GgrXPMghOnBB... \n", "198 672452 https://open.spotify.com/track/003vvx7Niy0yvhv... \n", "199 671326 https://open.spotify.com/track/64I6t2tuUGnIlaD... \n", "\n", "[200 rows x 5 columns]" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "csv_url = 'https://spotifycharts.com/regional/global/daily/latest/download'\n", "\n", "import pandas as pd\n", "import requests\n", "import io\n", "\n", "r = requests.get(csv_url)\n", "df = pd.read_csv(io.StringIO(r.text), skiprows=1)\n", "df" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[![Callysto.ca License](https://github.com/callysto/curriculum-notebooks/blob/master/callysto-notebook-banner-bottom.jpg?raw=true)](https://github.com/callysto/curriculum-notebooks/blob/master/LICENSE.md)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" } }, "nbformat": 4, "nbformat_minor": 4 }