평균 매출이 가장 높은 영화는?
평균적으로 어떤 영화가 가장 많은 티켓을 파는지도 궁금하시죠? 그러면 그 영화가 다른 상영관에서 시작될 때 어느 정도를 기대할 수 있을지 알 수 있어요.
theater_movie_summary에는 상영관 위치와 영화 제목 요약이 들어 있어, 평균 매출이 가장 좋은 영화를 찾는 데 도움이 될 거예요!
이 연습은 강의의 일부입니다
스프레드시트 사용자를 위한 Python
연습 안내
.groupby()와.mean()을 사용해movie_title별 평균 티켓 판매 요약 표를 만드세요.avg_sale_by_movie를ticket_quantity기준으로 내림차순 정렬하세요..head()와print()를 사용해movies_sorted의 첫 줄을 출력하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Summary of movies and locations
theater_movie_summary = sales.groupby(['theater_location', 'movie_title'], as_index=False).sum()
# Get average ticket sales by movie title
avg_sale_by_movie = theater_movie_summary.____(____, as_index=False).____()
# Sort average ticket sales in descending order
movies_sorted = avg_sale_by_movie.____(____, ascending=False).reset_index(drop=True)
# Print results
____