Tablesaw의 데이터 구조

Java에서 데이터 가져오기

Anthony Markham

VP Quant Developer

핵심 데이터 구조

  • Table: 기본 컨테이너(데이터프레임과 유사)
Table employees = Table.create("Employees");
  • Column: 동일한 타입의 값을 보관
StringColumn nameCol = StringColumn.create("Name");
  • Row: 개별 레코드
Row firstRow = employees.row(0);
Java에서 데이터 가져오기

테이블 메서드

String tableName = employees.name();
employees
// 행/열 개수
int rowCount = employees.rowCount();
int columnCount = employees.columnCount();
1000
5
Java에서 데이터 가져오기

열 타입

  • 강한 타입 = 각 열은 고정 데이터 타입
    • 성능 향상, 디버깅 용이
  • 예:
    • StringColumn - 텍스트 데이터
    • IntColumn, DoubleColumn - 수치 값
    • BooleanColumn - 참/거짓 값
    • 시계열 데이터:
      • DateColumn - 날짜(2024-03-05)
      • DateTimeColumn - 날짜시간(2024-03-05T14:32)
Java에서 데이터 가져오기

열 타입 연산

  • 각 타입은 특화 연산을 제공합니다
// DoubleColumn에서 .mean() 사용
DoubleColumn salary = employees.column("Salary");
double averageSalary = salary.mean();
Java에서 데이터 가져오기

데이터 접근

// 특정 열 가져오기
StringColumn names = employees.stringColumn("Name");

// 일반 열 가져오기 names = employees.column("Name");
// 열에서 값 가져오기 String firstPerson = names.get(0);
// 전체 행 가져오기 Row firstRow = employees.row(0);
// 행에서 값 가져오기 double salary = firstRow.getDouble("Salary");
Java에서 데이터 가져오기

선택(Selection)

  • 조건과 일치하는 행 인덱스의 집합
  • 예:
    • .isGreaterThan(), .isLessThan()
    • .isEqualTo()
    • .isAfter()

$$

// 행 선택 만들기
Selection highEarners = employees.doubleColumn("Salary")
    .isGreaterThan(70000);
Java에서 데이터 가져오기

선택으로 필터링

// 행 선택 만들기
Selection highEarners = employees.doubleColumn("Salary")
    .isGreaterThan(70000);


// 선택을 적용해 필터링된 테이블 얻기 Table highPaidEmployees = employees.where(highEarners);

$$

$$

  • .where()는 새 테이블을 반환합니다
Java에서 데이터 가져오기

불리언 연산

  • .and().or()로 선택을 결합
Selection recentHires = employees.dateColumn("HireDate")
    .isAfter(LocalDate.of(2020, 1, 1));

Selection highPaidRecent = highEarners.and(recentHires);
Java에서 데이터 가져오기

Ayo berlatih!

Java에서 데이터 가져오기

Preparing Video For Download...