Java 中的資料匯入
Anthony Markham
VP Quant Developer
Table employees = Table.create("Employees");
StringColumn nameCol = StringColumn.create("Name");
Row firstRow = employees.row(0);
String tableName = employees.name();
employees
// 列與欄數量
int rowCount = employees.rowCount();
int columnCount = employees.columnCount();
1000
5
StringColumn:文字資料IntColumn、DoubleColumn:數值BooleanColumn:True/False 值DateColumn:行事曆日期(2024-03-05)DateTimeColumn:日期時間(2024-03-05T14:32)// 在 DoubleColumn 上使用 .mean()
DoubleColumn salary = employees.column("Salary");
double averageSalary = salary.mean();
// 取得特定型別的欄 StringColumn names = employees.stringColumn("Name");// 取得一般欄 names = employees.column("Name");// 從欄位取得單一值 String firstPerson = names.get(0);// 取得整列資料 Row firstRow = employees.row(0);// 從列取得單一值 double salary = firstRow.getDouble("Salary");
.isGreaterThan()、.isLessThan().isEqualTo().isAfter()$$
// 建立列的選擇條件
Selection highEarners = employees.doubleColumn("Salary")
.isGreaterThan(70000);
// 建立列的選擇條件 Selection highEarners = employees.doubleColumn("Salary") .isGreaterThan(70000);// 套用選擇條件以取得過濾後的表格 Table highPaidEmployees = employees.where(highEarners);
$$
$$
.where() 會回傳新的表格.and() 與 .or() 組合選擇條件Selection recentHires = employees.dateColumn("HireDate") .isAfter(LocalDate.of(2020, 1, 1));Selection highPaidRecent = highEarners.and(recentHires);
Java 中的資料匯入