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

Jual Jupiter Z Road Race 5TP Karburator

04-Maret-2019 Bagi teman-teman semua yang lagi cari jupiter Z 5TP, saya jual Jupiter saya, motor sasisnya tidak pernah jatuh keras, masih stabil, mesin juga awet, karena saya beli barang-barang kelas atas. Motor sering juara, foto dibawah dapat juara 1 di Sentul Kecil, motor juga dibuat bengkel yang punya nama di Sentul. Spesifikasi Motor Yamaha Jupiter Z 1. Super Head BRT  Original , porting polished by R-Flamboyan Cilandak Jagakarsa 2. Blok BRT, Forged Piston  Original 3. Karburator Keihin PWK KX 28mm  Original 4. Close Ratio TDR Racing  Original 5.  Magnit Flywheel custom by R-Flamboyan Cilandak Jagakarsa 6. CDI BRT I Max 24 step  Original 7. Valve size 29mm Intake, dan 24mm Exhaust 8. Knalpot Custom Free Flow 9. Rocker Arm Racing Roller, Per Klep Racing 10. Camshaft full custom by R-Flamboyan Cilandak Jagakarsa 11. Crankcase Yamaha X-1  Original 12.  Velg TK Excel Asia R17  Original 13. Ban Depan Belak...

Podium 3 Underbone 4T NonPlus di Seri-3 D Event 6 Mei 2018 Sentul International Karting Circuit

Minggu pagi sekitar jam 7 saya baru sampai di sirkuit, R-Flamboyan Racing Family sudah sampai jam 6 pagi. Paddock dan motor sudah tertata rapih. Dijadwalkan sesi free practice pertama jam 7 pagi, untuk kelas Bebek atau Underbone ada di urutan kedua.

Bayar Pajak Mobil Jakarta Pusat Tahunan di Drive Thru Polda Metro Jaya Jakarta Selatan

27 Januari 2018 Masih ada 2-minggu lagi sebelum tempo pajak tahunan saya mati. Pagi-pagi jam 8 sudah meluncur ke Mall Gandaria City untuk ke Samsat Mall, karena memang biasanya bayar disitu, ehh ternyata, jadwal baru, sekarang buka nya jam 10, apes.  Ga abis akal, langsung ide saja meluncur ke Samsat polda metro jaya atau biasa disebut Komdak Jakarta Selatan. Kira-kira sampai di lokasi jam 9 lewat. Saat jalan menuju kedalam, wah loket drive thru ada mobil yang sedang proses, ohh ternyata bisa drive thru, tanya dulu ke petugas untuk konfirmasi, benar saja disarankan untuk bayar pajak tahunan lewat drive thru saja lebih cepat katanya 10 menit. Tertarik. Langsung masuk ke mobil dan mengarahkan ke area drive thru. 3 Dokumen yang disiapkan 1. STNK Asli + 1 copy

Perbaikan sistem Power Steering & Kaki - kaki Toyota Soluna Matic 2000 mulai bunyi lagi

24 July 2016 Sudah 2 minggu mendengar suara jedug - jedug di bagian kaki - kaki depan Toyota Soluna. tepatnya di bagian agak tengah kalo didengarkan baik-baik. Paling menyebalkan kalo harus ke Lippo Mall Kemang, yang boulevard jalannya menggunakan batu -  batu alam tidak rata, tiap lewat situ semakin gerah karena membuka aib semua kaki - kaki mobil :P,   dug dug, tok tok, pletak - pletak T_T.