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

Rusça tweet'lerde hashtag ve mention'lar

Rusça tweet'leri içeren tweets veri çerçevesine geri dönelim. Bu egzersizde, her tweetteki hashtag ve mention sayılarını hesaplayacaksın. Bunun için sırasıyla count_hashtags() ve count_mentions() adlı iki fonksiyon tanımlayıp tweets içindeki content özelliğine uygulayacaksın.

Hatırlatmak gerekirse, tweet'ler tweets veri çerçevesinin content özelliğinde yer alıyor.

Bu egzersiz

Python ile NLP için Özellik Mühendisliği

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

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Function that returns numner of hashtags in a string
def count_hashtags(string):
	# Split the string into words
    words = string.split()
    
    # Create a list of words that are hashtags
    hashtags = [word for word in words if ____.____(____)]
    
    # Return number of hashtags
    return(len(hashtags))

# Create a feature hashtag_count and display distribution
tweets['hashtag_count'] = tweets['content'].apply(count_hashtags)
tweets['hashtag_count'].hist()
plt.title('Hashtag count distribution')
plt.show()
Kodu Düzenle ve Çalıştır