शुरू करेंमुफ़्त में शुरू करें

Movies को integer id असाइन करना

आइए यही काम movies पर भी करें. फिर नए user IDs और movie IDs को जोड़कर एक ही dataframe में लाएँ.

यह अभ्यास पाठ्यक्रम का हिस्सा है

PySpark के साथ Recommendation Engines बनाना

पाठ्यक्रम देखें

अभ्यास निर्देश

  • ratings dataframe से सभी यूनिक Movies निकालने के लिए .select() और .distinct() मेथड्स का उपयोग करें.
  • coalesce() का उपयोग करके movies dataframe को एक ही partition में repartition करें.
  • दिए गए partial कोड को पूरा करें ताकि हर movie को यूनिक integer ID असाइन हो. नए कॉलम का नाम movieId रखें और resulting dataframe पर .persist() मेथड कॉल करें.
  • ratings dataframe को users dataframe से और उसके बाद movies dataframe से join करें. परिणाम को movie_ratings नाम दें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Extract the distinct movie id's
movies = ratings.select("____").distinct() 

# Repartition the data to have only one partition.
movies = movies.coalesce(____) 

# Create a new column of movieId integers. 
movies = movies.withColumn("____", monotonically_increasing_id()).____() 

# Join the ratings, users and movies dataframes
movie_ratings = ratings.join(____, "User", "left").join(____, "Movie", "left")
movie_ratings.show()
कोड संपादित करें और चलाएँ