Fakultas Ilmu Komputer UI

Commit bf41280e authored by Ahmad Dzikrul Fikri's avatar Ahmad Dzikrul Fikri
Browse files

Lab13 - 1806196806

parent f3f578c3
%% Cell type:code id: tags:
``` python
import pandas as pd
customers = pd.read_csv('data_pelanggan.txt', sep=' ', names = ['nama', 'jumlah','harga'])
pd.set_option('display.max_rows',None)
print(customers)
```
%%%% Output: stream
nama jumlah harga
0 LAUREN 497 7952000
1 HARRY 496 7936000
2 YPPOP 495 7920000
3 HENRY 494 7904000
4 ISABELLA 492 7872000
5 NOSAM 489 7824000
6 CHARLOTTE 487 7792000
7 CAASI 485 7760000
8 SIENNA 485 7760000
9 YLLOH 481 7696000
10 BETHANY 480 7680000
11 AIRAM 478 7648000
12 MORGAN 478 7648000
13 LOUIS 477 7632000
14 YMA 477 7632000
15 YELIAB 476 7616000
16 ISOBEL 476 7616000
17 ADLITAM 474 7584000
18 YECAL 468 7488000
19 REBMA 466 7456000
20 ACCEBER 463 7408000
21 NAIK 463 7408000
22 ALISHA 457 7312000
23 AMELIA 456 7296000
24 NAGOL 453 7248000
25 NATHAN 453 7248000
26 FREYA 451 7216000
27 ELLIOT 498 7171200
28 EVA 497 7156800
29 YLIME 446 7136000
30 YELIR 445 7120000
31 YAJ 443 7088000
32 HARRIET 437 6992000
33 YCUL 437 6992000
34 YLIL 436 6976000
35 HTEBAZILE 433 6928000
36 LUCAS 432 6912000
37 LOGAN 432 6912000
38 EITAK 477 6868800
39 IMOGEN 428 6848000
40 LIAM 428 6848000
41 COREY 428 6848000
42 AMME 426 6816000
43 OWEN 422 6752000
44 ALICE 419 6704000
45 BLAKE 418 6688000
46 NODNARB 415 6640000
47 LIAGIBA 412 6592000
48 SACUL 410 6560000
49 EILLOH 455 6552000
50 NORAA 406 6496000
51 EISOR 450 6480000
52 SEMAJ 405 6480000
53 LIBBY 404 6464000
54 REECE 404 6464000
55 ZARA 401 6416000
56 MOHAMMAD 400 6400000
57 NAWE 499 6387200
58 LEAH 499 6387200
59 EOZ 442 6364800
60 RUBY 396 6336000
61 BOCAJ 394 6304000
62 FINLEY 393 6288000
63 HARVEY 393 6288000
64 JAKE 392 6272000
65 MUHAMMAD 392 6272000
66 POPPY 392 6272000
67 YBOT 392 6272000
68 MOLLY 390 6240000
69 RONNOC 390 6240000
70 EIMAJ 433 6235200
71 BEN 388 6208000
72 TTELRACS 386 6176000
73 SIWEL 385 6160000
74 NOSIDAM 384 6144000
75 WEHTTAM 383 6128000
76 SARAH 382 6112000
77 NOTHSA 381 6096000
78 AIVILO 377 6032000
79 ANNA 377 6032000
80 CAITLIN 376 6016000
81 REUBEN 376 6016000
82 YBUR 374 5984000
83 MARTHA 374 5984000
84 AYAM 373 5968000
85 JASMINE 371 5936000
86 EILRAHC 410 5904000
87 KAZ 368 5888000
88 YALNIF 365 5840000
89 EIFLA 500 5760000
90 LUCA 360 5760000
91 SKYE 355 5680000
92 JOE 352 5632000
93 DAVID 351 5616000
94 SEBASTIAN 349 5584000
95 NEBUER 345 5520000
96 YLLIB 344 5504000
97 NAGEM 343 5488000
98 AIGROEG 341 5456000
99 HTIAF 340 5440000
100 DAMMAHOM 340 5440000
101 JACK 340 5440000
102 YSIAD 340 5440000
103 BRANDON 337 5392000
104 LILY 337 5392000
105 ISABEL 335 5360000
106 NYLEVE 334 5344000
107 SAMOHT 333 5328000
108 CAMERON 333 5328000
109 NICOLE 329 5264000
110 NAES 324 5184000
111 AIHPOS 321 5136000
112 JOHN 321 5136000
113 SOPHIE 320 5120000
114 ALLEBASI 320 5120000
115 YENTRUOC 318 5088000
116 LILLY 316 5056000
117 JOEL 310 4960000
118 EILLE 341 4910400
119 TOBY 305 4880000
120 LEOJ 303 4848000
121 MADA 303 4848000
122 ALEX 302 4832000
123 ECNEROLF 334 4809600
124 MULLAC 300 4800000
125 DAISY 299 4784000
126 YRRAH 298 4768000
127 SAM 298 4768000
128 DYLAN 298 4768000
129 ACUL 296 4736000
130 MILLIE 295 4720000
131 NEDYAJ 295 4720000
132 ALLE 295 4720000
133 HPESOJ 292 4672000
134 EMILY 324 4665600
135 NIMAJNEB 291 4656000
136 LEBASI 288 4608000
137 NAGROM 288 4608000
138 JACOB 285 4560000
139 RILEY 284 4544000
140 REBECCA 277 4432000
141 GRACE 277 4432000
142 RACSO 273 4368000
143 NAITSABES 273 4368000
144 LOLA 271 4336000
145 XAM 268 4288000
146 YBBIL 264 4224000
147 NIRE 263 4208000
148 FAITH 262 4192000
149 YNAHTEB 262 4192000
150 NEB 261 4176000
151 BRADLEY 261 4176000
152 LAYLA 261 4176000
153 LUKE 258 4128000
154 JAYDEN 256 4096000
155 YLLIT 253 4048000
156 ACSECNARF 253 4048000
157 SUMMER 252 4032000
158 NEDYAH 250 4000000
159 EMILIA 277 3988800
160 EKALB 276 3974400
161 CONNOR 248 3968000
162 PHOEBE 248 3968000
163 EYKS 275 3960000
164 NOSIRRAH 247 3952000
165 MAISIE 247 3952000
166 SYHR 247 3952000
167 ELIZABETH 273 3931200
168 EKUL 273 3931200
169 OSCAR 245 3920000
170 MARIA 244 3904000
171 NAHTE 244 3904000
172 AARON 243 3888000
173 TILLY 241 3856000
174 NOEL 240 3840000
175 ELLIS 266 3830400
176 ESME 263 3787200
177 OLIVIA 235 3760000
178 EKAJ 256 3686400
179 AILUJ 228 3648000
180 DRAWDE 225 3600000
181 BENJAMIN 223 3568000
182 WILLIAM 220 3520000
183 ROLYAT 219 3504000
184 LYDIA 218 3488000
185 ALEXANDRA 216 3456000
186 ACISSEJ 215 3440000
187 FRANCESCA 215 3440000
188 EBEOHP 237 3412800
189 ROBERT 212 3392000
190 ECILA 232 3340800
191 EIDDERF 231 3326400
192 JESSICA 207 3312000
193 NIAMH 205 3280000
194 EDWARD 227 3268800
195 ZACHARY 194 3104000
196 ARAZ 193 3088000
197 ZOE 193 3088000
198 HAYDEN 189 3024000
199 SILLE 187 2992000
200 EIHPOS 207 2980800
201 EGROEG 200 2880000
202 ARIEK 178 2848000
203 YEROC 177 2832000
204 BILLY 176 2816000
205 NOSIDDAM 174 2784000
206 NAREIK 174 2784000
207 MICHAEL 172 2752000
208 EGIAP 191 2750400
209 MAILLIW 171 2736000
210 JULIA 170 2720000
211 MAYA 169 2704000
212 HOLLY 168 2688000
213 IXEL 168 2688000
214 OEL 167 2672000
215 AMBER 165 2640000
216 MATILDA 163 2608000
217 AHSILA 163 2608000
218 LEXIE 162 2592000
219 XELA 160 2560000
220 TIA 157 2512000
221 ECARG 174 2505600
222 JAY 155 2480000
223 ADAM 152 2432000
224 GRACIE 150 2400000
225 DANIEL 149 2384000
226 ELYK 164 2361600
227 AIT 147 2352000
228 JAMES 147 2352000
229 EMSE 160 2304000
230 TAYLOR 142 2272000
231 KAI 141 2256000
232 ETHAN 155 2232000
233 FREDDIE 139 2224000
234 AHTRAM 139 2224000
235 EIBBA 152 2188800
236 MOHAMMED 133 2128000
237 THOMAS 132 2112000
238 ELEANOR 142 2044800
239 RYAN 125 2000000
240 COURTNEY 124 1984000
241 EVIE 137 1972800
242 TOILLE 122 1952000
243 AUHSOJ 120 1920000
244 LEBOSI 119 1904000
245 ALSI 117 1872000
246 FLORENCE 116 1856000
247 ALICIA 113 1808000
248 EVE 123 1771200
249 KIAN 110 1760000
250 NILTIAC 109 1744000
251 MAX 107 1712000
252 YRAHCAZ 107 1712000
253 NAVE 103 1648000
254 CHARLIE 101 1616000
%% Cell type:markdown id: tags:
diatas adalah Soal 1
%% Cell type:code id: tags:
``` python
kolom_pilihan = ['nama', 'jumlah']
print(customers.loc[10:20,kolom_pilihan]) #menampilkan beberapa kolom dan baris tabel
```
%%%% Output: stream
nama jumlah
10 BETHANY 480
11 AIRAM 478
12 MORGAN 478
13 LOUIS 477
14 YMA 477
15 YELIAB 476
16 ISOBEL 476
17 ADLITAM 474
18 YECAL 468
19 REBMA 466
20 ACCEBER 463
%% Cell type:code id: tags:
``` python
kolom_pilihan = ['nama', 'jumlah']
print(customers.loc[:,kolom_pilihan]) #menampilkan beberapa kolom tabel dan seluruh baris dengan indexer loc
```
%%%% Output: stream
nama jumlah
0 LAUREN 497
1 HARRY 496
2 YPPOP 495
3 HENRY 494
4 ISABELLA 492
5 NOSAM 489
6 CHARLOTTE 487
7 CAASI 485
8 SIENNA 485
9 YLLOH 481
10 BETHANY 480
11 AIRAM 478
12 MORGAN 478
13 LOUIS 477
14 YMA 477
15 YELIAB 476
16 ISOBEL 476
17 ADLITAM 474
18 YECAL 468
19 REBMA 466
20 ACCEBER 463
21 NAIK 463
22 ALISHA 457
23 AMELIA 456
24 NAGOL 453
25 NATHAN 453
26 FREYA 451
27 ELLIOT 498
28 EVA 497
29 YLIME 446
30 YELIR 445
31 YAJ 443
32 HARRIET 437
33 YCUL 437
34 YLIL 436
35 HTEBAZILE 433
36 LUCAS 432
37 LOGAN 432
38 EITAK 477
39 IMOGEN 428
40 LIAM 428
41 COREY 428
42 AMME 426
43 OWEN 422
44 ALICE 419
45 BLAKE 418
46 NODNARB 415
47 LIAGIBA 412
48 SACUL 410
49 EILLOH 455
50 NORAA 406
51 EISOR 450
52 SEMAJ 405
53 LIBBY 404
54 REECE 404
55 ZARA 401
56 MOHAMMAD 400
57 NAWE 499
58 LEAH 499
59 EOZ 442
60 RUBY 396
61 BOCAJ 394
62 FINLEY 393
63 HARVEY 393
64 JAKE 392
65 MUHAMMAD 392
66 POPPY 392
67 YBOT 392
68 MOLLY 390
69 RONNOC 390
70 EIMAJ 433
71 BEN 388
72 TTELRACS 386
73 SIWEL 385
74 NOSIDAM 384
75 WEHTTAM 383
76 SARAH 382
77 NOTHSA 381
78 AIVILO 377
79 ANNA 377
80 CAITLIN 376
81 REUBEN 376
82 YBUR 374
83 MARTHA 374
84 AYAM 373
85 JASMINE 371
86 EILRAHC 410
87 KAZ 368
88 YALNIF 365
89 EIFLA 500
90 LUCA 360
91 SKYE 355
92 JOE 352
93 DAVID 351
94 SEBASTIAN 349
95 NEBUER 345
96 YLLIB 344
97 NAGEM 343
98 AIGROEG 341
99 HTIAF 340
100 DAMMAHOM 340
101 JACK 340
102 YSIAD 340
103 BRANDON 337
104 LILY 337
105 ISABEL 335
106 NYLEVE 334
107 SAMOHT 333
108 CAMERON 333
109 NICOLE 329
110 NAES 324
111 AIHPOS 321
112 JOHN 321
113 SOPHIE 320
114 ALLEBASI 320
115 YENTRUOC 318
116 LILLY 316
117 JOEL 310
118 EILLE 341
119 TOBY 305
120 LEOJ 303
121 MADA 303
122 ALEX 302
123 ECNEROLF 334
124 MULLAC 300
125 DAISY 299
126 YRRAH 298
127 SAM 298
128 DYLAN 298
129 ACUL 296
130 MILLIE 295
131 NEDYAJ 295
132 ALLE 295
133 HPESOJ 292
134 EMILY 324
135 NIMAJNEB 291
136 LEBASI 288
137 NAGROM 288
138 JACOB 285
139 RILEY 284
140 REBECCA 277
141 GRACE 277
142 RACSO 273
143 NAITSABES 273
144 LOLA 271
145 XAM 268
146 YBBIL 264
147 NIRE 263
148 FAITH 262
149 YNAHTEB 262
150 NEB 261
151 BRADLEY 261
152 LAYLA 261
153 LUKE 258
154 JAYDEN 256
155 YLLIT 253
156 ACSECNARF 253
157 SUMMER 252
158 NEDYAH 250
159 EMILIA 277
160 EKALB 276
161 CONNOR 248
162 PHOEBE 248
163 EYKS 275
164 NOSIRRAH 247
165 MAISIE 247
166 SYHR 247
167 ELIZABETH 273
168 EKUL 273
169 OSCAR 245
170 MARIA 244
171 NAHTE 244
172 AARON 243
173 TILLY 241
174 NOEL 240
175 ELLIS 266
176 ESME 263
177 OLIVIA 235
178 EKAJ 256
179 AILUJ 228
180 DRAWDE 225
181 BENJAMIN 223
182 WILLIAM 220
183 ROLYAT 219
184 LYDIA 218
185 ALEXANDRA 216
186 ACISSEJ 215
187 FRANCESCA 215
188 EBEOHP 237
189 ROBERT 212
190 ECILA 232
191 EIDDERF 231
192 JESSICA 207
193 NIAMH 205
194 EDWARD 227
195 ZACHARY 194
196 ARAZ 193
197 ZOE 193
198 HAYDEN 189
199 SILLE 187
200 EIHPOS 207
201 EGROEG 200
202 ARIEK 178
203 YEROC 177
204 BILLY 176
205 NOSIDDAM 174
206 NAREIK 174
207 MICHAEL 172
208 EGIAP 191
209 MAILLIW 171
210 JULIA 170
211 MAYA 169
212 HOLLY 168
213 IXEL 168
214 OEL 167
215 AMBER 165
216 MATILDA 163
217 AHSILA 163
218 LEXIE 162
219 XELA 160
220 TIA 157
221 ECARG 174
222 JAY 155
223 ADAM 152
224 GRACIE 150
225 DANIEL 149
226 ELYK 164
227 AIT 147
228 JAMES 147
229 EMSE 160
230 TAYLOR 142
231 KAI 141
232 ETHAN 155
233 FREDDIE 139
234 AHTRAM 139
235 EIBBA 152
236 MOHAMMED 133
237 THOMAS 132
238 ELEANOR 142
239 RYAN 125
240 COURTNEY 124
241 EVIE 137
242 TOILLE 122
243 AUHSOJ 120
244 LEBOSI 119
245 ALSI 117
246 FLORENCE 116
247 ALICIA 113
248 EVE 123
249 KIAN 110
250 NILTIAC 109
251 MAX 107
252 YRAHCAZ 107
253 NAVE 103
254 CHARLIE 101
%% Cell type:code id: tags:
``` python
kondisi1 = customers['jumlah'] > 400
kondisi2 = customers['nama'].str.startswith('H')
kondisi = kondisi1 & kondisi2
print(customers[kondisi])
```
%%%% Output: stream
nama jumlah harga
1 HARRY 496 7936000
3 HENRY 494 7904000
32 HARRIET 437 6992000
35 HTEBAZILE 433 6928000
%% Cell type:code id: tags:
``` python
batas = int(input('masukan batas pemesanan yang ingin ditampilkan :'))
inisial = input('masukkan inisial dari pemesan :').upper()
kondisi1 = customers['jumlah'] > batas
kondisi2 = customers['nama'].str.startswith(inisial)
kondisi = kondisi1 & kondisi2
print(customers[kondisi])
```
%%%% Output: stream
nama jumlah harga
1 HARRY 496 7936000
3 HENRY 494 7904000
32 HARRIET 437 6992000
35 HTEBAZILE 433 6928000
%% Cell type:code id: tags:
``` python
batas = int(input('masukan batas pemesanan yang ingin ditampilkan :'))
inisial = input('masukkan inisial dari pemesan :').upper()
kondisi1 = customers['jumlah'] > batas
kondisi2 = customers['nama'].str.startswith(inisial)
kondisi = kondisi1 | kondisi2
print(customers[kondisi]) #hasil yang didapat jika menggunakan kondisi1 | kondisi2 adalah gabungan dari dua kondisi tersebut
```
%%%% Output: stream
nama jumlah harga
0 LAUREN 497 7952000
1 HARRY 496 7936000
2 YPPOP 495 7920000
3 HENRY 494 7904000
4 ISABELLA 492 7872000
5 NOSAM 489 7824000
6 CHARLOTTE 487 7792000
7 CAASI 485 7760000
8 SIENNA 485 7760000
9 YLLOH 481 7696000
10 BETHANY 480 7680000
11 AIRAM 478 7648000
12 MORGAN 478 7648000
13 LOUIS 477 7632000
14 YMA 477 7632000
15 YELIAB 476 7616000
16 ISOBEL 476 7616000
17 ADLITAM 474 7584000
18 YECAL 468 7488000
19 REBMA 466 7456000
20 ACCEBER 463 7408000
21 NAIK 463 7408000
22 ALISHA 457 7312000
23 AMELIA 456 7296000
24 NAGOL 453 7248000
25 NATHAN 453 7248000
26 FREYA 451 7216000
27 ELLIOT 498 7171200
28 EVA 497 7156800
29 YLIME 446 7136000
30 YELIR 445 7120000
31 YAJ 443 7088000
32 HARRIET 437 6992000
33 YCUL 437 6992000
34 YLIL 436 6976000
35 HTEBAZILE 433 6928000
36 LUCAS 432 6912000
37 LOGAN 432 6912000
38 EITAK 477 6868800
39 IMOGEN 428 6848000
40 LIAM 428 6848000
41 COREY 428 6848000
42 AMME 426 6816000
43 OWEN 422 6752000
44 ALICE 419 6704000
45 BLAKE 418 6688000
46 NODNARB 415 6640000
47 LIAGIBA 412 6592000
48 SACUL 410 6560000
49 EILLOH 455 6552000
50 NORAA 406 6496000
51 EISOR 450 6480000
52 SEMAJ 405 6480000