Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import java.util.Arrays;
  2. import tech.tablesaw.api.DoubleColumn;
  3. import tech.tablesaw.api.Row;
  4. import tech.tablesaw.api.Table;
  5.  
  6. import static tech.tablesaw.aggregate.AggregateFunctions.*;
  7. public class Main {
  8.  
  9. public static void main(String[] args) {
  10. double[] obligacje = {55.44, 12.22, 41.33, 131.11};
  11. double[] kupon = {13.55,123.33, 141.11, 55.141};
  12. Table df = Table.create("obligacjexkupony").addColumns(
  13. DoubleColumn.create("Obligacje", obligacje),
  14. DoubleColumn.create("Kupon", kupon)
  15. );
  16.  
  17. System.out.println(df.print());
  18. System.out.println(df.structure());
  19. Table filteredDf = df.where(t -> t.doubleColumn("Obligacje").isLessThanOrEqualTo(50));
  20. System.out.println(filteredDf.print());
  21.  
  22. Table summary = df.summarize(Arrays.asList("Obligacje", "Kupon"), mean, sum, min, max).apply();
  23. System.out.println(summary.print());
  24.  
  25. df.stream().forEach(Main::calculate);
  26. System.out.println(df.print());
  27.  
  28.  
  29. }
  30.  
  31. private static void calculate(Row row) {
  32. double obligacja = row.getDouble("Obligacje");
  33. double kupon = row.getDouble("Kupon");
  34. row.setDouble("Obligacje", obligacja + kupon * 1.04);
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement