관리 메뉴

JIHYUN JEONG

[Spotify Data Analysis/스포티파이 데이터 분석] MySQL DB Insert 한 데이터 select 조회하기 (2) 본문

Data Science

[Spotify Data Analysis/스포티파이 데이터 분석] MySQL DB Insert 한 데이터 select 조회하기 (2)

StopHyun 2020. 3. 13. 17:13

 

2019년도 Spotify 에서 가장 많이 스트림된 곡들을 아래 데이터 셋에서 가져온 후 

 

https://www.kaggle.com/prasertk/spotify-global-2019-moststreamed-tracks

 

Spotify global 2019 most-streamed tracks

top 1,717 tracks with audio features and artist info

www.kaggle.com

 

판다스에서 가수들만 추려서 csv로 만든 뒤 Mysql DB Insert 한 뒤 쿼리 예시이다.

 

 

총 488명의 가수 데이터를 가지고 Spotify API를 사용해서 artist 정보와 arist genres 정보를 Insert 한 결과를 select 해보았다.

 

mysql> select count(*) from artists;
+----------+
| count(*) |
+----------+
|      481 |
+----------+
1 row in set (0.00 sec)

mysql> select count(*) from artist_genres;
+----------+
| count(*) |
+----------+
|     1746 |
+----------+
1 row in set (0.01 sec)

 

mysql> select genre, count(*) from artist_genres group by 1 order by 2 desc limit 20;
+------------------+----------+
| genre            | count(*) |
+------------------+----------+
| pop              |      158 |
| dance pop        |       86 |
| rap              |       71 |
| post-teen pop    |       71 |
| pop rap          |       67 |
| trap             |       48 |
| latin            |       40 |
| tropical house   |       36 |
| hip hop          |       35 |
| edm              |       33 |
| reggaeton        |       32 |
| rock             |       28 |
| southern hip hop |       25 |
| melodic rap      |       23 |
| adult standards  |       23 |
| german hip hop   |       22 |
| uk pop           |       22 |
| electropop       |       19 |
| funk carioca     |       17 |
| pop rock         |       17 |
+------------------+----------+
20 rows in set (0.01 sec)

 

mysql> select popularity, name from artists order by 1 desc limit 20;
+------------+---------------+
| popularity | name          |
+------------+---------------+
|        100 | Bad Bunny     |
|         96 | Justin Bieber |
|         96 | J Balvin      |
|         96 | Post Malone   |
|         96 | Drake         |
|         96 | Billie Eilish |
|         95 | The Weeknd    |
|         95 | BTS           |
|         95 | Eminem        |
|         94 | Travis Scott  |
|         94 | Juice WRLD    |
|         94 | Lil Uzi Vert  |
|         94 | Ed Sheeran    |
|         93 | Ozuna         |
|         93 | Anuel AA      |
|         93 | Lil Baby      |
|         93 | Khalid        |
|         93 | Roddy Ricch   |
|         93 | Sech          |
|         92 | Taylor Swift  |
+------------+---------------+
20 rows in set (0.00 sec)

 

mysql> select followers, name from artists order by 1 desc limit 20;
+-----------+-----------------+
| followers | name            |
+-----------+-----------------+
|  60579611 | Ed Sheeran      |
|  45229662 | Drake           |
|  43272379 | Ariana Grande   |
|  36619266 | Rihanna         |
|  33518180 | Eminem          |
|  33505325 | Justin Bieber   |
|  27390238 | Taylor Swift    |
|  25827798 | Imagine Dragons |
|  24867780 | Coldplay        |
|  24735999 | Shawn Mendes    |
|  24288135 | Queen           |
|  24261122 | Bruno Mars      |
|  23171027 | Post Malone     |
|  22947196 | Maroon 5        |
|  22317871 | Billie Eilish   |
|  22153657 | Beyoncé         |
|  22044173 | Marshmello      |
|  22043105 | Ozuna           |
|  21065906 | David Guetta    |
|  20265650 | Adele           |
+-----------+-----------------+
20 rows in set (0.01 sec)

 

mysql> select genre, COUNT(*) from artists t1 join artist_genres t2 on t2.artist_id = t1.id where t1.popularity > 80 group by 1 order by 2 desc limit 20;
+------------------+----------+
| genre            | COUNT(*) |
+------------------+----------+
| pop              |       84 |
| rap              |       46 |
| pop rap          |       43 |
| dance pop        |       40 |
| post-teen pop    |       36 |
| trap             |       30 |
| latin            |       25 |
| reggaeton        |       22 |
| hip hop          |       22 |
| melodic rap      |       18 |
| tropical house   |       16 |
| southern hip hop |       15 |
| edm              |       14 |
| uk pop           |       10 |
| r&b              |       10 |
| atl hip hop      |        9 |
| trap latino      |        8 |
| alternative r&b  |        8 |
| electropop       |        7 |
| pop rock         |        6 |
+------------------+----------+
20 rows in set (0.01 sec)

 

 


자 Select 한 결과를 요약하면

1. 장르는 pop이 158개로 가장 많았다

2. 인기(popularity)는 Bad Bunny가 현재 1위 이다. BTS도 상위권 95점

3. 현재 가장 많은 follower를 보유한 가수는 Ed Sheeran 이다. 60579611 명

 

4. 인기도가 80이상인 가수(artist)들 가운데 가장 많은 장르는 1위 pop(84 counts) 이다.

 

이 글이 도움이 되셨으면, 아래의 클릭 or 위/아래 광고 클릭을 부탁드립니다. (여러분의 클릭지속적인 콘텐츠를 작성하는데 큰 도움이 됩니다^^)

Buy Me A Coffee

 

감사합니다.

Comments