Algorithm/Python

[stratascratch] Count the number of movies that Abigail Breslin nominated for oscar(Python)

yujin.me 2021. 8. 7. 19:22

문제

Count the number of movies that Abigail Breslin nominated for oscar

Count the number of movies that Abigail Breslin was nominated for an oscar.

애비게일 브레슬린이 오스카에 노미네이트한 영화 수 세기

코드

# Import your libraries
import pandas as pd

# Start writing code
# solution 1
result = oscar_nominees[oscar_nominees['nominee'] == 'Abigail Breslin']
len(result)

# solution 2
result = oscar_nominees[oscar_nominees['nominee'].isin(['Abigail Breslin'])]
len(result)
  • nominee인 열에 Abigail Breslin이 들어있는 조건을 줘서 뽑기
  • 행의 개수를 뽑아줌

출처

반응형