{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 📈 Billboard Data\n", "This notebook uses the [billboard.py](https://github.com/guoguo12/billboard-charts) library." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "pycharm": { "is_executing": true } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Ran on: 24/11/2022\n" ] } ], "source": [ "from datetime import date\n", "from collections import Counter\n", "from dateutil.relativedelta import relativedelta\n", "import billboard\n", "import pandas as pd\n", "import numpy as np\n", "\n", "today = date.today().strftime(\"%d/%m/%Y\")\n", "print('Ran on: ' + today)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "currentHot100 = billboard.ChartData('hot-100')" ] }, { "cell_type": "code", "execution_count": 33, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
titleartistpeakPoslastPosweeksrankisNew
0Anti-HeroTaylor Swift1141False
1Rich FlexDrake & 21 Savage2222False
2UnholySam Smith & Kim Petras11083False
3Bad HabitSteve Lacy113204False
4As It WasHarry Styles117335False
........................
95The Great WarTaylor Swift2687496False
96Gotta Move OnDiddy & Bryson Tiller7999797False
97Forget MeLewis Capaldi950598False
98Going, Going, GoneLuke Combs990199True
99Bigger Than The Whole SkyTaylor Swift21854100False
\n", "

100 rows × 7 columns

\n", "
" ], "text/plain": [ " title artist peakPos lastPos \\\n", "0 Anti-Hero Taylor Swift 1 1 \n", "1 Rich Flex Drake & 21 Savage 2 2 \n", "2 Unholy Sam Smith & Kim Petras 1 10 \n", "3 Bad Habit Steve Lacy 1 13 \n", "4 As It Was Harry Styles 1 17 \n", ".. ... ... ... ... \n", "95 The Great War Taylor Swift 26 87 \n", "96 Gotta Move On Diddy & Bryson Tiller 79 99 \n", "97 Forget Me Lewis Capaldi 95 0 \n", "98 Going, Going, Gone Luke Combs 99 0 \n", "99 Bigger Than The Whole Sky Taylor Swift 21 85 \n", "\n", " weeks rank isNew \n", "0 4 1 False \n", "1 2 2 False \n", "2 8 3 False \n", "3 20 4 False \n", "4 33 5 False \n", ".. ... ... ... \n", "95 4 96 False \n", "96 7 97 False \n", "97 5 98 False \n", "98 1 99 True \n", "99 4 100 False \n", "\n", "[100 rows x 7 columns]" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def convert_ChartData_to_array(chart):\n", " songs = []\n", " for chartEntry in chart:\n", " song = {\n", " 'title': chartEntry.title,\n", " 'artist': chartEntry.artist,\n", " 'peakPos': chartEntry.peakPos,\n", " 'lastPos': chartEntry.lastPos,\n", " 'weeks': chartEntry.weeks,\n", " 'rank': chartEntry.rank,\n", " 'isNew': chartEntry.isNew\n", " }\n", " songs.append(song)\n", " return songs\n", "\n", "hot100Array = convert_ChartData_to_array(currentHot100)\n", "hot100DF = pd.DataFrame(hot100Array)\n", "hot100DF\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 📆 Sort by Weeks on the Hot 100" ] }, { "cell_type": "code", "execution_count": 20, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
titleartistpeakPoslastPosweeksrankisNew
22Wasted On YouMorgan Wallen9375323False
24All I Want For Christmas Is YouMariah Carey105225False
40Rockin' Around The Christmas TreeBrenda Lee204641False
49Jingle Bell RockBobby Helms304350False
4As It WasHarry Styles117335False
........................
57Treacherous TwinsDrake & 21 Savage1414258False
66Middle Of The OceanDrake1515267False
90Break My HeartRod Wave910191True
85Heart Like A TruckLainey Wilson860186True
98Going, Going, GoneLuke Combs990199True
\n", "

100 rows × 7 columns

\n", "
" ], "text/plain": [ " title artist peakPos lastPos \\\n", "22 Wasted On You Morgan Wallen 9 37 \n", "24 All I Want For Christmas Is You Mariah Carey 1 0 \n", "40 Rockin' Around The Christmas Tree Brenda Lee 2 0 \n", "49 Jingle Bell Rock Bobby Helms 3 0 \n", "4 As It Was Harry Styles 1 17 \n", ".. ... ... ... ... \n", "57 Treacherous Twins Drake & 21 Savage 14 14 \n", "66 Middle Of The Ocean Drake 15 15 \n", "90 Break My Heart Rod Wave 91 0 \n", "85 Heart Like A Truck Lainey Wilson 86 0 \n", "98 Going, Going, Gone Luke Combs 99 0 \n", "\n", " weeks rank isNew \n", "22 53 23 False \n", "24 52 25 False \n", "40 46 41 False \n", "49 43 50 False \n", "4 33 5 False \n", ".. ... ... ... \n", "57 2 58 False \n", "66 2 67 False \n", "90 1 91 True \n", "85 1 86 True \n", "98 1 99 True \n", "\n", "[100 rows x 7 columns]" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hot100DF.sort_values(by='weeks', ascending=False)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 🔥 The hotest Artists\n", "Find the Artists that has had the largest number of songs on the Hot 100 in the last 10 years.\n", "\n", "The date taken is today and then incrementally minuses a year for the past 10 years.\n", "\n", "I dont want to break my computer by doing every single day of every singe year." ] }, { "cell_type": "code", "execution_count": 73, "metadata": {}, "outputs": [], "source": [ "def all_entries_last_10_years(chartName):\n", " currentDate = date.today()\n", " tenYearCharts = []\n", " for i in range(1, 10):\n", " yearChart = billboard.ChartData(chartName, date= currentDate.strftime(\"%Y-%m-%d\"))\n", " yearChartAsArray = convert_ChartData_to_array(yearChart)\n", " year = currentDate.year\n", " tenYearCharts = np.concatenate([tenYearCharts, yearChartAsArray])\n", " currentDate = currentDate - relativedelta(years=1)\n", " return tenYearCharts" ] }, { "cell_type": "code", "execution_count": 78, "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", "
0
IU34
Lee Mujin3
Gaeko, Ourealgoat, SINCE, Ahn Byeong Woong, Tabber, Gwangil Jo Prod. CODE KUNST1
aespa3
sokodomo Feat. Zion.T, Wonstein, Prod. by Slom1
\n", "
" ], "text/plain": [ " 0\n", "IU 34\n", "Lee Mujin 3\n", "Gaeko, Ourealgoat, SINCE, Ahn Byeong Woong, Tab... 1\n", "aespa 3\n", "sokodomo Feat. Zion.T, Wonstein, Prod. by Slom 1" ] }, "execution_count": 78, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tenYearHot100 = all_entries_last_10_years('hot-100')\n", "def get_artist_count(chart):\n", " artists = []\n", " for chartEntry in chart:\n", " artists.append(chartEntry['artist'])\n", " artistCount = Counter(artists)\n", " return artistCount\n", "\n", "hot100ArtistCountDF = pd.DataFrame.from_dict(get_artist_count(tenYearHot100), orient='index')\n", "\n", "hot100ArtistCountDF.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 💜 Kpop" ] }, { "cell_type": "code", "execution_count": 79, "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", "
0
IU34
Lee Mujin3
Gaeko, Ourealgoat, SINCE, Ahn Byeong Woong, Tabber, Gwangil Jo Prod. CODE KUNST1
aespa3
sokodomo Feat. Zion.T, Wonstein, Prod. by Slom1
......
Brown Eyed Soul5
BewhY5
GIRIBOY (Feat. Jvcki Wai)5
MONSTA X5
SuperM5
\n", "

166 rows × 1 columns

\n", "
" ], "text/plain": [ " 0\n", "IU 34\n", "Lee Mujin 3\n", "Gaeko, Ourealgoat, SINCE, Ahn Byeong Woong, Tab... 1\n", "aespa 3\n", "sokodomo Feat. Zion.T, Wonstein, Prod. by Slom 1\n", "... ..\n", "Brown Eyed Soul 5\n", "BewhY 5\n", "GIRIBOY (Feat. Jvcki Wai) 5\n", "MONSTA X 5\n", "SuperM 5\n", "\n", "[166 rows x 1 columns]" ] }, "execution_count": 79, "metadata": {}, "output_type": "execute_result" } ], "source": [ "kpopTenYearChart = all_entries_last_10_years('billboard-korea-100')\n", "kpopArtistCountDF = pd.DataFrame.from_dict(get_artist_count(kpopTenYearChart), orient='index')\n", "kpopArtistCountDF" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "korea chart (current)\n", "---------------------\n", "1. 'Gone Not Around Any Longer' by Sistar19\n", "2. 'Bounce' by Cho Yong Pil\n", "3. 'My Love' by Lee Seung Chul\n", "4. 'Shower Of Tears' by BAE CHI GI (Feat. Ailee)\n", "5. 'Turtle' by Davichi\n", "6. 'What's Your Name?' by 4Minute\n", "7. 'Bom Bom Bom' by Roy Kim\n", "8. 'Give It To Me' by SISTAR\n", "9. 'Bar Bar Bar' by Crayon Pop\n", "10. 'Monodrama' by Huh Gak (With Yoo Seung Woo)\n", "11. 'Tears' by Leessang (Feat. Eugene of The SEEYA)\n", "12. 'NoNoNo' by Apink\n", "14. 'Touch Love' by Yoon Mi Rae (T)\n", "15. 'Winter Love' by The One\n", "16. 'Gentleman' by PSY\n", "17. 'I'm Sorry' by CNBLUE\n", "18. 'What's Wrong With My Age' by Oh Seung-Keun\n", "19. 'GROWL' by EXO\n", "20. 'I Got A Boy' by Girls' Generation\n", "21. 'Cherry Blossom Ending' by Busker Busker\n", "22. 'Crazy of You' by Hyorin\n", "23. 'Hands Of The Clock' by Shinyoo\n", "24. 'Snow Flower' by Gummy\n", "25. 'Missing You Today' by Davichi\n", "26. 'Crescendo' by Akdong Musician (AKMU)\n", "27. 'All Right' by Lim Kim\n", "28. 'First Marriage' by Jang Yoon Jeong\n", "29. 'I Love You' by Akdong Musician (AKMU)\n", "30. 'Return' by Lee Seung Gi\n", "31. 'Story Of Someone I Know' by San E\n", "32. 'Love Blossom' by K.Will\n", "33. 'Yoo Hoo' by Secret\n", "34. 'Rose' by LeeHi\n", "35. 'And One' by Tae Yeon (of Girls' Generation)\n", "36. 'Short Hair' by Huh Gak, Jung Eunji (Apink)\n", "37. 'Don't Think You're Alone' by Kim Bo Kyung\n", "38. 'Life As a Floating Weed' by Kim Yong Im\n", "39. 'Don't You Know' by Davichi\n", "40. '1440' by Huh Gak\n", "41. 'Gangbuk Fancy Pants' by Jung Hyung Don\n", "42. 'Stupid In Love' by Soyou & Mad Clown\n", "43. 'Shadow' by BEAST\n", "44. 'Crooked' by G-Dragon\n", "45. 'BAAAM' by Dynamic Duo (Feat. Muzie Of UV)\n", "46. 'Rum Pum Pum Pum' by f(x)\n", "47. 'Bad Girls' by Lee Hyo Ri\n", "48. 'Only You' by 4Men\n", "49. 'Miss Korea' by Lee Hyo Ri\n", "50. 'Be Warmed' by Davichi (Feat. Verbal Jint)\n", "51. 'FALLING IN LOVE' by 2NE1\n", "52. 'I Hate It' by Baek Ji Young\n", "53. 'One Spring Day' by 2AM\n", "54. 'To You' by Sung Si-Kyung\n", "55. 'Love, At First' by Busker Busker\n", "56. 'Bad Girl' by Bumkey (Feat. E-sens Of Supreme Team)\n", "57. 'Expectation' by Girl's Day\n", "58. 'Dream Girl' by SHINee\n", "59. 'Miss Right' by Teen Top\n", "60. 'Hello It's Me' by 4Men\n", "61. 'Attraction' by Bumkey (Feat. Dynamic Duo)\n", "62. 'Best Wishes To You' by The One\n", "63. 'Propose Song' by 4Men\n", "64. 'Why Did You Come Just Now' by Jung Yup\n", "65. 'Tonight' by Lyn (Feat. Baechigi)\n", "66. 'Goodbye To Romance' by Sunny Hill\n", "67. 'Hello' by Cho Yong Pil (Feat. VerbalJint)\n", "68. 'Black' by G-Dragon (Feat. Jennie Kim Of YG New Artist)\n", "69. 'I'm in Love' by 2BiC\n", "70. 'Be OK' by Yu Seong Eun (Feat. Baechigi)\n", "71. 'Day And Night' by Gummy\n", "72. 'Caffeine' by Yang Yo Seob (Beast) (Feat. Junhyung of B2ST)\n", "73. 'Special Girl' by Infinite H Featuring Bumkey\n", "74. 'Don't Forget Me' by Suzy\n", "75. 'Foreigner's Confessions' by Akdong Musician (AKMU)\n", "76. 'Dancing Queen' by Girls' Generation\n", "77. 'Good Start' by Verbal Jint (Feat. Kang Min Hee Of Miss $)\n", "78. 'Break Up Dinner' by San E (Feat. Sanchez of Phantom)\n", "79. 'It's Over' by LeeHi\n", "80. 'Female President' by Girl's Day\n", "81. 'The Red Shoes' by IU\n", "82. 'The Way You Make Me Melt' by SISTAR (Feat. Geeks)\n", "83. 'Man In Love' by INFINITE\n", "84. '24 Hours' by SUNMI\n", "85. 'For The Last Time' by VIBE\n", "86. 'What's Happening' by B1a4\n", "87. 'Do You Love Me' by 2NE1\n", "88. 'Officially Missing You, Too' by Geeks, SoYu\n", "89. 'Bean Ice Flakes With Rice Cake' by Akdong Musician (AKMU)\n", "90. 'The Letter' by Davichi\n", "91. 'Who You?' by G-Dragon\n", "92. 'Is It Ramyun' by Akdong Musician (AKMU)\n", "93. 'Hush' by miss A\n", "94. 'That You're Mine' by Huh Gak (Feat. Swings)\n", "95. 'Cosmic Girl' by Kim Tae Woo\n", "96. 'Will You Be Alright?' by BEAST\n", "97. 'How About' by GEEKS (Feat. Hareem)\n", "98. 'Destiny' by INFINITE\n", "99. 'Is It Poppin?' by 4Minute\n", "100. 'I Can't Live Because Of You' by Seo In Kuk (Feat. Verbal Jint)\n" ] } ], "source": [ "print(billboard.ChartData('korea'))\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.12" } }, "nbformat": 4, "nbformat_minor": 4 }