Skip to main content

Introduction to Data Science Version 3

Exercises 13.4 Chapter Challenges

1.

Create a function that takes as input a dataframe of tweets and returns as output a list of all of the retweet screennames. As an extra challenge, see if you can reduce that list of screennames to a unique set (i.e., no duplicates) while also generating a count of the number of times that each retweet screenname appeared.

2.

Once you have written that function, it should be a simple matter to copy and modify it to create a new function that extracts a unique list of hashtags from a dataframe of tweets. Recall that hashtags begin with the β€œ#” character and may contain any combination of upper and lowercase characters as well as digits. There is no length limit on hashtags, so you will have to assume that a hashtag ends when there is a space or a punctuation mark such as a comma, semicolon, or period.