concept word frequency in category pyspark
appears as: word frequency, word frequencies

This is an excerpt from Manning's book Data Analysis with Python and PySpark.
Before continuing our data processing journey, we can take a step back and look at a sample of the data. Just by looking at the 15 rows returned, we can see that
Prejudice,has a comma and that the cell betweenAustenandThiscontains the empty string. That gives us a good blueprint of the next steps that needs to be performed before we start analyzing word frequency.
Listing 3.1. Counting word frequencies using
groupby()andcount()groups = words_nonull.groupby(col("word")) groups # <pyspark.sql.group.GroupedData at 0x10ed23da0> results = words_nonull.groupby(col("word")).count() results # DataFrame[word: string, count: bigint] results.show() # +-------------+-----+ # | word|count| # +-------------+-----+ # | online| 4| # | some| 203| # | still| 72| # | few| 72| # | hope| 122| # | those| 60| # | cautious| 4| # | lady's| 8| # | imitation| 1| # | art| 3| # | solaced| 1| # | poetry| 2| # | arguments| 5| # | premeditated| 1| # | elevate| 1| # | doubts| 2| # | destitute| 1| # | solemnity| 5| # |gratification| 1| # | connected| 14| # +-------------+-----+ # only showing top 20 rows