Aan de slagGa gratis aan de slag

String operations

Now that you can load the text data into bags, it is time to actually do something with it. To detect how positive or negative the reviews are, you will start by counting some keywords.

The bag you created in the last exercise, review_bag, is available in your environment.

Deze oefening maakt deel uit van de cursus

Parallel Programming with Dask in Python

Cursus bekijken

Oefeninstructies

  • Use the .lower() method of review_bag's string accessor to convert each review to lower case.
  • Use the .count() method of the string accessor to count how many times the word 'excellent' appears in each review.
  • Print 10 values of excellent_counts.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Convert all of the reviews to lower case
lowercase_reviews = review_bag.____

# Count the number of times 'excellent' appears in each review
excellent_counts = lowercase_reviews.____

# Print the first 10 counts of 'excellent'
print(____)
Code bewerken en uitvoeren