Nhập dữ liệu trong Java
Anthony Markham
VP Quant Developer
.selectColumns() tạo một Table mới// Chọn các cột theo tên
Table nameAndSalary = employees.selectColumns("Name", "Salary");
// Chọn theo kiểu cột
Table numericColumns = employees.selectColumns(
column -> column.type().equals(ColumnType.DOUBLE) ||
column.type().equals(ColumnType.INTEGER));
.where()Table mới// Lọc với một điều kiện
Table seniors = employees.where(
employees.intColumn("Age").isGreaterThanOrEqualTo(65));
// Lọc với nhiều điều kiện
Table targetGroup = employees.where(
employees.intColumn("Age").isBetweenInclusive(30, 50)
.and(employees.doubleColumn("Salary")
.isGreaterThan(75000)));
.sortOn().sortDescendingOn() để sắp xếp giảm dần// Sắp xếp theo một cột (tăng dần)
Table sortedBySalary = employees.sortOn("Salary");
// Sắp xếp theo nhiều cột (hướng tùy chọn)
Table complexSort = employees
.sortOn("Department")
.sortDescendingOn("Salary");
.summarize()import tech.tablesaw.aggregate.AggregateFunctions.*;
// Tóm tắt lương
Table deptSummary = employees.summarize("Salary", mean, count, max).apply();
| Mean [Salary] | Count [Salary] | Max [Salary] |
|---|---|---|
| 113606.20299999935 | 1000 | 199793 |
// Nhiều phép tổng hợp
Table complexSummary = employees.summarize(
"Salary", "Age",
mean, median, min, max).apply();
| Mean [Salary] | Median [Salary] | Min [Salary] | Max [Salary] | Mean [Age] | Median [Age] | Min [Age] | Max [Age] |
|---|---|---|---|---|---|---|---|
| 113606.2029 | 112667 | 30301 | 199793 | 45.6699 | 46 | 22 | 70 |
.select() - Chọn các cột cụ thểTable selected = employees.select("Name", "Salary");
.where() - Lọc hàng theo điều kiệnTable filtered = employees.where(condition);
.sortOn() - Sắp xếp theo cộtTable sorted = employees.sortOn("Department", "Salary");
.summarize() - Tính thống kêTable summary = employees.summarize("Salary", mean, max).apply();
Nhập dữ liệu trong Java