본문 바로가기

Algorithm/Python

[stratascratch] find the top 10 ranked songs in 2010(Python)

문제

Find the top 10 ranked songs in 2010

What were the top 10 ranked songs in 2010? Output the rank, group name, and song name but do not show the same song twice. Sort the result based on the year_rank in ascending order.

2010년에 top10에 들었던 노래 조회하기. 같은 노래가 중복되면 안되고, year_rank를 기준 오름차순으로 정렬하라

코드

# Import your libraries
import pandas as pd

# Start writing code
billboard_top_100_year_end.head()
billboard_top_100_year_end[
	(billboard_top_100_year_end['year'] == 2010)&(billboard_top_100_year_end['year_rank'] <= 10)
]
[['year_rank','group_name','song_name']].drop_duplicates().sort_values(by=['year_rank'], axis=0)

출처

반응형