#python과 #rstats 비교하기
이제 트윗 곳곳에 단어가 있는지 확인하는 함수를 만들었으니, 여러 단어에 적용해 비교해 볼 수 있어요. 데이터 사이언스 해시태그 데이터셋 예시로 돌아가 보겠습니다. #python과 비교해서 #rstats가 몇 번 등장하는지 확인해 보려고 해요.
데이터 사이언스 해시태그 데이터셋 ds_tweets는 미리 로드되어 있어요.
이 연습은 강의의 일부입니다
Python으로 소셜 미디어 데이터 분석하기
연습 안내
- 함수
check_word_in_tweet()을 사용해ds_tweets의 텍스트 필드에서#python의 모든 발생을 찾으세요. - 같은 방법으로
#rstats도 찾으세요. np.sum()으로python을 합산하고 이를ds_tweets.shape[0]로 나눠#python을 언급한 트윗의 비율을 출력하세요.rstats도 같은 방식으로 하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Find mentions of #python in all text fields
python = ____(____, ds_tweets)
# Find mentions of #rstats in all text fields
rstats = ____(____, ____)
# Print proportion of tweets mentioning #python
print("Proportion of #python tweets:", ____(____) / ____)
# Print proportion of tweets mentioning #rstats
print("Proportion of #rstats tweets:", ____(____) / ____)