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

Mengemis di Qatar Melawan Hukum Article 1 of Law No. 28 of 2006

Sebagai negara terkaya di middle east no.1 tahun 2024 (dan no.1 di dunia jika berdasarkan GDP [Million QR 686.288]), secara logika seluruh manusia yang hidup di atas tanah Qatar memiliki kecukupan. Kita tidak akan membahas warga asli Qatar, karena sudah jelas sudah makmur. Imigran yang datang ke Qatar adalah pekerja-pekerja skilled bisa di cek di Planning and Statistical Authority Qatar Data sensus 2020, memperlihatkan bahwasannya, imigran non qatari yang ada 30% lulusan universitas dan hanya 27% yg lulusan SD, bisa baca tulis, dan buta huruf, sisanya skilled worker semua, statement saya diatas bukan tanpa data. Jadi sangat wajar apabila hukum  Artikel 1 Law No. 28 tahun 2006 ini di implementasikan, bahwasannya secara logika tidak ada fakir yang pantas untuk meminta-minta di Qatar. Law No. 11 of 2004 Issuing the Penal Code Article 278 - (Amended By Law 28 /2006) Starting Date: 27/07/2006 (replaced by Article 1 of Law No. 28 of 2006) Whoever begs in roads or public places, leads or ...

Tata Cara Klaim Garansi GoPro 2019

18 Mar 2019 GoPro Hero6 Hero7, baru beli, umur dibawah setahun, mati total, kena air, bocor air laut, air kolam (khusus karena air, jangan di kasih tau), atau salah charge, atau mati tiba-tiba, mau garansi TAM, garansi toko, ga masalah, Klaim Garansi ke GoPro.com aja, asalkan nota/kuitansi beli (print/tulis tangan stempel toko) ada, bukti beli di online juga bisa. Proses ga ribet, tinggal tunggu dijemput aja GoPro nya, mantab. Step nya 1. Siapkan GoPro nya, kartu garansi yang distempel toko dan nota pembelian yang di stempel toko, bukti pembelian online (bila ada) misal pakai bukalapak, tokopedia dan semacamnya, hidupkan PC atau laptop, di HP biasanya tidak bisa, karena chat keluar pop up. 2. Buka https://community.gopro.com/s/contactus?language=en_US, sekarang 24jam support nya jadi bisa chat kapan saja. 3. Mulai lah chat, biasanya akan di tanya nomor seri GoPro, lihat di dalam wadah baterai kalau hero5, angkanya C1xxxxxxx, Hero7 C3xxxxxxxx

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.

PostgreSQL Cari text tanpa peduli besar kecil dan posisi

  Select the  title  and  description  columns from the  film  table. Perform a full-text search on the  title  column for the word  elf . -- Select the title and description SELECT   title ,   description FROM   film -- Convert the title to a tsvector and match it against the tsquery  WHERE   to_tsvector ( title )   @@   to_tsquery ( 'elf' ); title description GHOSTBUSTERS ELF A Thoughtful Epistle of a Dog And a Feminist who must Chase a Composer in Berlin ELF MURDER A Action-Packed Story of a Frisbee And a Woman who must Reach a Girl in An Abandoned Mine Shaft ENCINO ELF A Astounding Drama of a Feminist And a Teacher who must Confront a Husband in A Baloon