Importing Data in Java
Anthony Markham
VP Quant Developer
.selectColumns() vytvoří nový objekt Table// Výběr konkrétních sloupců podle názvu
Table nameAndSalary = employees.selectColumns("Name", "Salary");
// Výběr podle typu sloupce
Table numericColumns = employees.selectColumns(
column -> column.type().equals(ColumnType.DOUBLE) ||
column.type().equals(ColumnType.INTEGER));
.where()Table// Filtrování jednou podmínkou
Table seniors = employees.where(
employees.intColumn("Age").isGreaterThanOrEqualTo(65));
// Filtrování více podmínkami
Table targetGroup = employees.where(
employees.intColumn("Age").isBetweenInclusive(30, 50)
.and(employees.doubleColumn("Salary")
.isGreaterThan(75000)));
.sortOn().sortDescendingOn() pro sestupné řazení// Řazení podle jednoho sloupce (vzestupně)
Table sortedBySalary = employees.sortOn("Salary");
// Řazení podle více sloupců (vlastní směr)
Table complexSort = employees
.sortOn("Department")
.sortDescendingOn("Salary");
.summarize()import tech.tablesaw.aggregate.AggregateFunctions.*;
// Souhrn platu
Table deptSummary = employees.summarize("Salary", mean, count, max).apply();
| Mean [Salary] | Count [Salary] | Max [Salary] |
|---|---|---|
| 113606.20299999935 | 1000 | 199793 |
// Více agregací najednou
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() - Výběr konkrétních sloupcůTable selected = employees.select("Name", "Salary");
.where() - Filtrování řádků podle podmínekTable filtered = employees.where(condition);
.sortOn() - Řazení dat podle sloupcůTable sorted = employees.sortOn("Department", "Salary");
.summarize() - Výpočet statistikTable summary = employees.summarize("Salary", mean, max).apply();
Importing Data in Java