BaşlayınÜcretsiz Başlayın

Comparing #python to #rstats

Now that we have a function to check whether or not the word is in the tweet in multiple places, we can deploy this across multiple words and compare them. Let's return to our example with the data science hashtag dataset. We want to see how many times that #rstats occurs compared to #python.

The data science hashtag dataset ds_tweets has been loaded for you.

Bu egzersiz

Analyzing Social Media Data in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Use the function check_word_in_tweet() to find all instances of #python in the text fields of ds_tweets.
  • Do the same with #rstats.
  • Print proportion of tweets mentioning #python by summing python with np.sum() and dividing it by ds_tweets.shape[0].
  • Do the same for rstats.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# 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:", ____(____) / ____)
Kodu Düzenle ve Çalıştır