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

DIY [Do It Yourself] Perbaikan Kisi - kisi Blower AC Mobil Soluna yang patah

Mau share sedikit ilmu yang didapat dari browsing - browsing di internet, Cara hemat dan murah memperbaiki kisi - kisi AC mobil Soluna atau mobil lain yang tipe nya sama / mirip (keluaran tahun 2000 an). Biasanya kisi - kisi jenis ini problemnya adalah sudu - sudu pengarah arah anginnya sudah tidak bisa di perintah bergerak kiri atau kekanan, dan problemnya karena batang penyatu semua sudu - sudu getas dan patah.

Do It Yourself Ganti Roller CVT Nouvo/Mio

26 Maret 2014 Ada waktu senggang lagi buat oprek motor, melalui discuss di group kaskus, ada yang memberi masukan, untuk menggunakan roller 9gram agar tarikan bawah / akselerasi lebih bagus. Saya tebus aja roller KTC 9gram di mandala motor mampang, seharga Rp.67.500. Oh iya, sebelumnya si nouvo pake roller kombinasi 12gram dan 7 gram (rencananya roller nya mau dijual kali laku :P)  ini linknya Oke langsung ke main action Bongkar2 CVT Tools yang diperlukan, kunci L, kunci sok 17, karena saya mendukung safety jadi pake sarung tangan, biar keren

Podium 3 Seri Perdana Mesin Potong Rumput GP, Balap Gokart, Exhibition Class

Sabtu, 3 Februari 2018 Bale Kota Mall Tangerang, Jakarta, di Sirkuit Lamtoro Karting, saya mengikuti kejuaraan Balap Gokart, MPRGP, kelas exhibition. Kelas ini diramaikan oleh 12 starter, lomba dijalankan dua sesi, Heat-1 atau Kualifikasi dan Final. Gokart dan grid start di dapat dengan sistem random dari acakan laptop (microsoft Excel) asik juga cara panitia mesin potong rumput GP buat sistem undiannya. Seingat saya, saya mendapatkan gokart dengan nomor 8, kondisi setir kurang baik, tetapi performa mesin oke,

API Human Factor 2005

Saat anda mendesain suatu peralatan teknis yang memerlukan interface dengan operator. Seperti Panel, Control Station, HMI (Human Machine Interface), Push Button, Valve, anda harus mempertimbangkan human factor atau usernya. Jika peralatan tersebut dipasang di Asia atau di Eropa tentunya tinggi akses akan berbeda karena tinggi average atau rata-rata personel di area tersebut ditentukan oleh faktor genetika nya. Hadirlah API Human Factor menjadi guideline (tapi ini tentunya terbatas di US saja datanya, untuk asia silahkan di sesuaikan), bisa menggunakan data di bps.go.id melihat data statistik morfologi manusia khususnya di Indonesia.

Kajian Muslim Indonesia Bada Solat Jumat Masjid Amr bin Jundub West Bay Doha Qatar 16 Agustus 2024

Kajian translate khotbah jumat oleh Ustad Zubair di akhiri dgn makan siang bersama. Khitbah ttg kesempurnaan solat, khususnya sukud 7titik harus bertemu kepala/wajah, kedua tangan, kedua lutut dan kedua kaki. Pak Jendral Sudriman juga cerita ttg awal mula kajian ini yg sudah berijin resmi utk melakukan kegiatan dan bagaimana awalnya saat masjid masih belum representative untuk melakukan acara seperti ini krn mah blum ada listrik krn bangunan baru jadi.