LoslegenKostenlos starten

Character count of Russian tweets

In this exercise, you have been given a dataframe tweets which contains some tweets associated with Russia's Internet Research Agency and compiled by FiveThirtyEight.

Your task is to create a new feature 'char_count' in tweets which computes the number of characters for each tweet. Also, compute the average length of each tweet. The tweets are available in the content feature of tweets.

Be aware that this is real data from Twitter and as such there is always a risk that it may contain profanity or other offensive content (in this exercise, and any following exercises that also use real Twitter data).

Diese Übung ist Teil des Kurses

<Kurs>Feature Engineering for NLP in Python</Kurs>
Kurs ansehen

Übungsanweisungen

  • Create a new feature char_count by applying len to the 'content' feature of tweets.
  • Print the average character count of the tweets by computing the mean of the 'char_count' feature.

Interaktive praktische Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Create a feature char_count
tweets['char_count'] = tweets[____].apply(____)

# Print the average character count
print(tweets[____].____)
Code bearbeiten und ausführen