-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpertemuan13.html
More file actions
325 lines (290 loc) · 14.4 KB
/
pertemuan13.html
File metadata and controls
325 lines (290 loc) · 14.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<!doctype html>
<html lang="en" data-theme="light">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="lms-url" content="https://lms.itera.ac.id">
<title>Pertemuan 13 - CSV File</title>
<link rel="stylesheet" href="dist/reset.css">
<link rel="stylesheet" href="dist/reveal.css">
<link rel="stylesheet" href="dist/theme/simple.css">
<!-- Custom PKOM Theme (Shared Style) -->
<link rel="stylesheet" href="css/pkom-theme.css">
<!-- Syntax highlighting -->
<link rel="stylesheet" href="plugin/highlight/monokai.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
</head>
<body>
<button class="theme-toggle" type="button" aria-label="Toggle theme" title="Toggle theme"><i class="bi bi-moon"></i></button>
<div class="reveal">
<!-- Persistent Footer -->
<div class="footer-branding">
<div class="footer-logos">
<img src="logo/logo_itera.png" alt="Logo ITERA">
<img src="logo/logo_kampus_berdampak.png" alt="Logo Kampus Merdeka">
</div>
<div class="footer-copyright">
© 2026 Institut Teknologi Sumatera
</div>
</div>
<div class="slides">
<!-- === SLIDE 1: JUDUL === -->
<section>
<div class="title-box">
<h1>Pengenalan Komputasi</h1>
<h3 class="subtitle">Pertemuan 13: File External (CSV)</h3>
</div>
</section>
<!-- === SLIDE 2: OUTLINE === -->
<section>
<h3>Outline Materi</h3>
<div class="flex-container" style="align-items: flex-start;">
<div class="flex-col card">
<h4 style="font-size: 0.9em; border-bottom: 2px solid #eee; padding-bottom: 10px;">Teori</h4>
<ul style="font-size: 0.7em;">
<li>Apa itu CSV?</li>
<li>Intro to Data Cleaning</li>
<li>Pandas <code>read_csv</code></li>
</ul>
</div>
<div class="flex-col card">
<h4 style="font-size: 0.9em; border-bottom: 2px solid #eee; padding-bottom: 10px;">Praktek</h4>
<ul style="font-size: 0.7em;">
<li>Membaca File CSV</li>
<li>Filtering & Sorting Data</li>
<li>Menangani Missing Values</li>
<li><strong>Hands-on Practice</strong></li>
</ul>
</div>
</div>
</section>
<!-- === SLIDE 3: APA ITU CSV === -->
<section>
<h3>Apa itu CSV?</h3>
<div class="flex-container">
<div class="flex-col text-left text-small">
<p><strong>CSV (Comma Separated Values)</strong> adalah format teks sederhana untuk menyimpan
data tabular.</p>
<p>Banyak digunakan untuk pertukaran data antara aplikasi (Excel ↔ Python ↔ Database).
</p>
</div>
<div class="flex-col card">
<p class="text-smaller">Contoh isi file <code>data.csv</code>:</p>
<pre><code class="text">
Nama,Umur,Kota
Budi,20,Jakarta
Siti,21,Bandung
Andi,19,Surabaya
</code></pre>
<p class="text-smaller" style="margin-top: 8px; color: #666;">
<strong>Penjelasan:</strong> Baris pertama adalah header/kolom. Setiap baris berikutnya adalah satu record data mahasiswa dengan 3 atribut: nama, umur, dan kota asal.
</p>
</div>
</div>
</section>
<!-- === SLIDE 4: MEMBACA CSV === -->
<section>
<h3>Membaca CSV dengan Pandas</h3>
<p class="text-small"><code>pd.read_csv()</code> adalah fungsi utama untuk membaca file CSV ke dalam DataFrame pandas.</p>
<div class="card" style="max-width: 650px; margin: 0 auto;">
<pre><code class="python" data-trim>
import pandas as pd
df = pd.read_csv('mahasiswa.csv')
# Inspeksi data
print(df.head()) # Preview 5 baris
print(df.info()) # Struktur & tipe data
print(df.describe()) # Statistik deskriptif
</code></pre>
<p class="text-smaller" style="margin-top: 6px; color: #666;">
Otomatis deteksi header & tipe data. <code>head()</code> preview, <code>info()</code> struktur, <code>describe()</code> statistik.
</p>
</div>
</section>
<!-- === SLIDE 5: DATA CLEANING (MISSING) === -->
<section>
<h3>Data Cleaning: Missing Values</h3>
<p class="text-small">Data di dunia nyata seringkali kotor/kosong.</p>
<pre><code class="python" data-trim>
# Cek data kosong (True/False)
print(df.isnull().sum())
# Solusi 1: Hapus baris yang kosong
df_bersih = df.dropna()
# Solusi 2: Isi dengan nilai default (ex: 0)
df_isi = df.fillna(0)
# Solusi 3: Isi dengan Rata-rata
mean_umur = df['Umur'].mean()
df['Umur'] = df['Umur'].fillna(mean_umur)
</code></pre>
</section>
<!-- === SLIDE 6: DATA MANIPULATION - FILTERING === -->
<section>
<h3>Data Manipulation: Filtering</h3>
<p class="text-small">Mengambil baris data yang memenuhi kondisi tertentu.</p>
<div class="card" style="max-width: 700px; margin: 0 auto;">
<pre><code class="python" data-trim>
import pandas as pd
df = pd.read_csv('mahasiswa.csv')
# Filter berdasarkan kondisi tunggal
senior = df[df['Umur'] > 20]
jkt = df[df['Kota'] == 'Jakarta']
# Filter dengan multiple conditions
muda_jkt = df[(df['Umur'] < 21) &
(df['Kota'] == 'Jakarta')]
# Filter dengan string methods
nama_a = df[df['Nama'].str.startswith('A')]
</code></pre>
<p class="text-smaller" style="margin-top: 8px; color: #666;">
Gunakan operator <code>&</code> (AND), <code>|</code> (OR), dan <code>~</code> (NOT) untuk kombinasi kondisi.
</p>
</div>
</section>
<!-- === SLIDE 7: DATA MANIPULATION - SORTING === -->
<section>
<h3>Data Manipulation: Sorting</h3>
<p class="text-small">Mengurutkan data berdasarkan kolom tertentu.</p>
<div class="card" style="max-width: 700px; margin: 0 auto;">
<pre><code class="python" data-trim>
# Urutkan ascending (kecil ke besar)
df_urut_umur = df.sort_values('Umur')
# Urutkan descending (besar ke kecil)
df_desc = df.sort_values('Umur', ascending=False)
# Urutkan berdasarkan multiple columns
df_multi = df.sort_values(['Kota', 'Umur'])
</code></pre>
<p class="text-smaller" style="margin-top: 8px; color: #666;">
Parameter <code>ascending=False</code> untuk descending.
</p>
</div>
</section>
<!-- === SLIDE 8: DATA CLEANING (DUPLICATES) === -->
<section>
<h3>Membersihkan Duplikat</h3>
<pre><code class="python" data-trim>
# Cek jumlah duplikat
print(df.duplicated().sum())
# Hapus duplikat
df = df.drop_duplicates()
</code></pre>
<p class="text-small">Penting agar analisis tidak bias karena data ganda.</p>
</section>
<!-- === SLIDE 9: LATIHAN HANDS-ON === -->
<section>
<h3>Hands-On: Analisis Penjualan</h3>
<div class="card text-left">
<p class="text-small">Diberikan file <code>transaksi.csv</code> (Produk, Jumlah, Harga).</p>
<ol class="text-small">
<li>Load file menggunakan Pandas.</li>
<li>Buat kolom baru <code>Total</code> = Jumlah * Harga.</li>
<li>Hitung <strong>Total Omset</strong> (Sum dari kolom Total).</li>
<li>Tampilkan transaksi dengan Jumlah > 10.</li>
<li>Urutkan data berdasarkan Total (descending) dan tampilkan 5 transaksi teratas.</li>
<li>Hapus duplikat jika ada.</li>
</ol>
</div>
</section>
<!-- === SLIDE 10: RINGKASAN === -->
<section>
<h3>Ringkasan Hari Ini</h3>
<ul class="text-small">
<li><i class="bi bi-check-circle"></i> <strong><code>read_csv()</code></strong>: Membaca file CSV.</li>
<li><i class="bi bi-check-circle"></i> <strong><code>to_csv()</code></strong>: Menyimpan DataFrame ke CSV.</li>
<li><i class="bi bi-check-circle"></i> <strong><code>dropna()</code></strong>: Menghapus data kosong.</li>
<li><i class="bi bi-check-circle"></i> <strong><code>fillna()</code></strong>: Mengisi data kosong.</li>
<li><i class="bi bi-check-circle"></i> <strong><code>drop_duplicates()</code></strong>: Menghapus data duplikat.</li>
</ul>
</section>
<!-- === SLIDE 11: TUGAS === -->
<section>
<h3>Tugas Pertemuan 13 <i class="bi bi-list-check"></i></h3>
<div class="card card-warning text-left">
<ul class="text-small">
<li><strong>Analisis Data Nilai:</strong>
<br>- Baca <code>nilai_mhs.csv</code>.
<br>- Bersihkan data kosong (Isi nilai kosong dengan 0).
<br>- Tambahkan kolom <code>Status</code> ("Lulus" jika Nilai >= 60).
<br>- Simpan hasil ke <code>nilai_bersih.csv</code>.
</li>
<li><strong>Visualisasi Distribusi Nilai:</strong>
<br>- Buat histogram distribusi nilai mahasiswa.
<br>- Tambahkan bar chart jumlah mahasiswa lulus vs tidak lulus.
<br>- Simpan visualisasi sebagai file gambar (<code>distribusi_nilai.png</code>).
</li>
</ul>
</div>
</section>
<!-- === SLIDE 12: PANDUAN PENGERJAAN === -->
<section>
<h3>Panduan Pengerjaan Tugas</h3>
<div class="card card-info text-left">
<p class="text-small">Langkah penting untuk menyelesaikan tugas:</p>
<ul class="text-smaller">
<li><strong>Data Processing:</strong> Baca CSV → Bersihkan missing values → Manipulasi DataFrame → Simpan hasil.</li>
<li><strong>Visualization:</strong> Buat histogram distribusi nilai dan bar chart status kelulusan dengan matplotlib.</li>
<li><strong>Code Quality:</strong> Gunakan komentar jelas dan pastikan kode dapat dijalankan tanpa error.</li>
<li><strong>File Output:</strong> Pastikan semua file (CSV & PNG) tersimpan dengan benar sebelum upload.</li>
</ul>
</div>
</section>
<!-- === SLIDE 13: PENGUMPULAN TUGAS === -->
<section>
<h3>Pengumpulan Tugas</h3>
<div class="card card-warning text-left">
<div class="flex-container" style="align-items: center;">
<div class="flex-col text-left">
<p class="text-smaller"><strong>Instruksi:</strong></p>
<ul class="text-smaller">
<li>Simpan file: <code>Tugas13_NIM_Nama.py</code></li>
<li>Sertakan file CSV hasil (<code>nilai_bersih.csv</code>).</li>
<li>Sertakan file gambar visualisasi (<code>distribusi_nilai.png</code>).</li>
<li>Upload ke LMS sebelum deadline.</li>
</ul>
</div>
<div class="flex-col text-center">
<div style="font-size: 3em;"><i class="bi bi-exclamation-triangle"></i></div>
<p class="text-smaller"><strong>Deadline:</strong><br>H-1 Pertemuan Berikutnya</p>
</div>
</div>
</div>
</section>
<!-- === SLIDE 14: NEXT WEEK === -->
<section>
<h3>Pertemuan Berikutnya</h3>
<h4>Final Mini Project & Algoritma <i class="bi bi-rocket"></i></h4>
<p class="text-small">Persiapan tugas akhir kelompok.</p>
<ul class="text-small" style="columns: 2;">
<li>Pembagian Kelompok</li>
<li>Topik Project</li>
<li>Rubrik Penilaian</li>
<li>Design Algoritma</li>
</ul>
</section>
<!-- === SLIDE 15: Q&A === -->
<section>
<h1>Q & A</h1>
<p>Terima Kasih!</p>
<div class="text-smaller" style="margin-top: 50px; color: #666;">
Sampai jumpa! <i class="bi bi-hand-wave"></i>
</div>
</section>
</div>
</div>
<script src="js/theme-toggle.js"></script>
<script src="dist/reveal.js"></script>
<script src="plugin/notes/notes.js"></script>
<script src="plugin/markdown/markdown.js"></script>
<script src="plugin/highlight/highlight.js"></script>
<script>
Reveal.initialize({
hash: true,
progress: true,
center: true,
transition: 'slide',
slideNumber: 'c/t',
plugins: [RevealMarkdown, RevealHighlight, RevealNotes]
});
</script>
<script src="js/emoji-to-icons.js"></script>
<script src="js/auto-layout.js"></script>
<script src="js/slide-enhancements.js"></script>
</body>
</html>