Langsung ke konten utama

ETL Extract Transform Load

  • Complete the transform_avg_rating() function by grouping by the course_id column, and taking the mean of the rating column.
  • Use extract_rating_data() to extract raw ratings data. It takes in as argument the database engine db_engines.
  • Use transform_avg_rating() on the raw rating data you've extracted.
  • Mencari kesamaan antar user 1 2 3 berdasarkan rating yang di input di sistem

Now that you have a grasp of what's happening in the datacamp_application database, let's go ahead and write up a query for that database.

The goal is to get a feeling for the data in this exercise. You'll get the rating data for three sample users and then use a predefined helper function, print_user_comparison(), to compare the sets of course ids these users rated.

  • Complete the connection URI. The database is called datacamp_application. The host is localhost with port 5432. The username is repl and the password is password.
  • Select the ratings of users with id: 438718163 and 8770.
  • Fill in print_user_comparison() with the three users you selected.

# Complete the connection URI

connection_uri = "postgresql://repl:password@localhost:5432/datacamp_application" 
db_engine = sqlalchemy.create_engine(connection_uri)

# Get user with id 4387
user1 = pd.read_sql("SELECT * FROM rating WHERE user_id=4387", db_engine)

# Get user with id 18163
user2 = pd.read_sql("SELECT * FROM rating WHERE user_id=18163", db_engine)

# Get user with id 8770
user3 = pd.read_sql("SELECT * FROM rating WHERE user_id=8770", db_engine)

# Use the helper function to compare the 3 users
print_user_comparison(user1, user2, user3)


Course id overlap between users:

================================ User 1 and User 2 overlap: {32, 96, 36, 6, 7, 44, 95} User 1 and User 3 overlap: set() User 2 and User 3 overlap: set()


Mencari Average Rating

In this exercise, you'll complete a transformation function transform_avg_rating() that aggregates the rating data using the pandas DataFrame's .groupby() method. The goal is to get a DataFrame with two columns, a course id and its average rating:

course_idavg_rating
1234.72
1114.62

In this exercise, you'll complete this transformation function, and apply it on raw rating data extracted via the helper function extract_rating_data() which extracts course ratings from the rating table.


  • Complete the transform_avg_rating() function by grouping by the course_id column, and taking the mean of the rating column.
  • Use extract_rating_data() to extract raw ratings data. It takes in as argument the database engine db_engines.
  • Use transform_avg_rating() on the raw rating data you've extracted

# Complete the transformation function
def transform_avg_rating(rating_data):
    # Group by course_id and extract average rating per course
    avg_rating = rating_data.groupby('course_id').rating.mean()
    # Return sorted average ratings per course
    sort_rating = avg_rating.sort_values(ascending=False).reset_index()
    return sort_rating

# Extract the rating data into a DataFrame    
rating_data = extract_rating_data(db_engines)

# Use transform_avg_rating on the extracted data and print results
avg_rating_data = transform_avg_rating(rating_data)
print(avg_rating_data) 

course_id rating 0 46 4.800000 1 23 4.800000 2 96 4.692765 3 56 4.661765 4 24 4.653061 .. ... ... 94 54 4.238095 95 92 4.222222 96 29 4.208333 97 17 4.147059 98 42 4.107570



Komentar

Postingan populer dari blog ini

Pompa Air Booster Shimizu PS 135 E Otomatis Bermasalah & Cara Menangulangi nya

Pengunaan pompa air untuk Booster sering kali digunakan untuk rumah bertingkat. Biasanya pompa booster bekerja otomatis, bisa menggunakan pressure switch atau flow switch. Penggunaan pressure switch lebih banyak, karena lebih murah dan kebanyakan sudah merupakan fitur standar dari manufaktur pompa. Kali ini saya akan membagi pengalaman menggunakan Pompa Booster Shimizu PS-135 E menggunakan pressure switch. Pembelian pompa 11 April 2015 sudah cukup berumur 4tahun usianya. Problem yang biasa terjadi untuk pompa booster tipe pressure switch. 1. Pompa On-Off dengan jeda sangat pendek ketika keran di buka 1/4 atau setengah, bahasa lainnya cetak cetek, cetek cetek 2. Pompa On terus tidak pernah mati 3. Pompa tidak mau menyala Kita bahas satu persatu

Catatan Noob Dad : Denver II Test Perkembangan Kemampuan Motorik, Bahasa, Sosial

Kalau Denver II ini guidance ilmiah, di umur berapa kita expect anak kita melakukan apa. Ya selaen kata orang tua, ini dia guidance nya, dan ga perlu di banding-bandingkan dengan anak tetangga. Karena test ini pun ada persentase nya.

Ganti Oli Matic Soluna 2001 Oli Castrol Dexron III - 7April2017

7 April 17 Hampir aja lupa ganti oli si Luna, nanti pengaruh ke performa lagi, mengingat umur si Luna yang tidak lagi belia hehehehe. KM170.000 harusnya udah ganti oli, ehh 173.000KM baru inget ganti gara-gara baru liat penanda oli. Meluncur ke bengkel Worner Matic di seputaran Bintaro, disamping Pasar Modern Bintaro. Sudah telpon dulu sebelumnya ke nomor yang ada di Google 0812-1015-018. Janji jam 1 siang untuk penggantian oli. Sebelum penggantian ada tanya jawab singkat dulu dengan sang pemilik bengkel, orangnya sangat informatif dan mengerti pemilihan oli matic untuk mobil - mobil, dari tahun 1990 - 2000, 2000-2010 , sampai dengan 2010-2017 (sekarang). Untuk Soluna disarankan menggunakan ATF seri Dex III (tiga). Luna masih belum CVT, masih matic konvensional. Dua macam merk oli ditawarkan 1. Prestone Multi-Vehicle Synthetic ATF Rp.85.000,- (harga tidak mengikat dan merupakan hak bengkel untuk menaikkan atau menurunkan) 2. Castrol ATF Dex III Harga Rp.80.000,- (harga...

Macam-macam ukuran ban sepeda 2024 reference Schwalbe

16 April 2024 Drop Bar & Hybrid Ban 700C RB Gravel Komuter Ban nya roadbike , tapi sepeda komuter dan sepeda gravel juga Pada umumnya ban 700c yang tipis dan slick (tanpa pola) bagus untuk kecepatan di jalan yang mulus. Ukuran 23mm, 25mm , 32mm biasa terpakai di roadbike, saya sendiri menggunakan 28mm karena jalanan Indonesia tidak terlalu mulus, dari pengalaman jarang bocor karena ban lebih tebal daripada 23mm (pure roadbike).