인기도 분위수 계산하기
streams, monthly_listeners, popularity 같은 지표가 포함된 25개의 인기 앨범으로 구성된 Spotify 데이터셋을 계속 분석합니다. 마케팅 팀에서는 성과가 낮은 앨범, 보통 수준의 앨범, 급성장 앨범을 명확한 구간으로 나누길 원합니다. 인기도가 어떻게 분포하는지 이해할 수 있도록 분위수를 계산하세요.
polars는 pl로 로드되어 있습니다. 스트리밍 지표를 담은 DataFrame spotify가 미리 준비되어 있습니다.
이 연습은 강의의 일부입니다
Polars로 하는 데이터 변환
연습 안내
popularity열을 선택하고 25번째 분위수를 계산한 뒤,q25_popularity라는 별칭으로 지정하세요.- 50번째와 75번째 분위수도 계산해 각각 알맞은 별칭으로 추가하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Calculate the 25th, 50th, and 75th percentiles of popularity
result = spotify.select(
pl.col("____").____(0.25).alias("q25_popularity"),
pl.col("popularity").quantile(____).alias("q50_popularity"),
pl.col("popularity").quantile(____).alias("q75_popularity"),
)
print(result)