July 2017
Beginner to intermediate
420 pages
10h 56m
English
Well, Pandas keeps making it easy for us, and has a corrwith function that you can see in the following code that we can use:
similarMovies = movieRatings.corrwith(starWarsRatings) similarMovies = similarMovies.dropna() df = pd.DataFrame(similarMovies) df.head(10)
That code will go ahead and correlate a given column with every other column in the DataFrame, and compute the correlation scores and give that back to us. So, what we're doing here is using corrwith on the entire movieRatings DataFrame, that's that entire matrix of user movie ratings, correlating it with just the starWarsRatings column, and then dropping all of the missing results with dropna. So, that just leaves us with items that had a correlation, where ...
Read now
Unlock full access