Mengimpor Data di Java
Anthony Markham
VP Quant Developer
.drop().addColumns()// Hapus kolom tertentu Table cleaned = dataTable.drop("TempID", "Notes");// Tambah dua kolom baru StringColumn statusCol = StringColumn.create("Status", "Active", "Inactive", "Active"); IntColumn priorityCol = IntColumn.create("Priority", 1, 2, 3); Table enhanced = dataTable.addColumns(statusCol, priorityCol);
Selection untuk kriteria penyaringan// Buat kondisi seleksi Selection outliers = dataTable.doubleColumn("Value") .isLessThan(lowerBound) .or(dataTable.doubleColumn("Value") .isGreaterThan(upperBound));// Hapus baris yang sesuai kondisi Table cleanedData = dataTable.dropWhere(outliers);
.rowCount() - hitung jumlah baris dalam tabel// Bandingkan jumlah baris
System.out.println("Baris asli: " + dataTable.rowCount());
System.out.println("Setelah menghapus outlier: " +
cleanedData.rowCount());
Baris asli: 100
Setelah menghapus outlier: 95
and, or, not// Penyaringan boolean kompleks Selection techHighPaid = dataTable.stringColumn("Department") .isEqualTo("Technology") .and(dataTable.doubleColumn("Salary") .isGreaterThan(100000));// Seleksi invers (NOT) Selection nonTechOrLowPaid = techHighPaid.not();
// Ubah seluruh kolom dengan fungsi yang telah ditentukan
StringColumn upperNames = dataTable.stringColumn("Name").map(s -> s.toUpperCase());
// Ubah nilai dalam kolom DoubleColumn prices = dataTable.doubleColumn("Price"); DoubleColumn discounted = prices.map(price -> price * 0.9);// Tetapkan nama dan tambahkan kolom discounted.setName("DiscountedPrice"); Table withDiscounts = dataTable.addColumns(discounted);
.drop() - Hapus kolom dari tabel.dropWhere() - Hapus baris yang sesuai kondisi.addColumns() - Tambah kolom baru ke tabel.map() - Ubah nilai kolom// Metode manipulasi lanjutan inti
dataTable.drop("TemporaryID");
dataTable.dropWhere(selection);
dataTable.addColumns(newColumn);
doubleCol.map(value -> value * 2);
Mengimpor Data di Java