Skip to content

Instantly share code, notes, and snippets.

@ko-sasaki
Last active February 1, 2026 06:54
Show Gist options
  • Select an option

  • Save ko-sasaki/5d1d2f6a152cd76dbbf3f54e12510994 to your computer and use it in GitHub Desktop.

Select an option

Save ko-sasaki/5d1d2f6a152cd76dbbf3f54e12510994 to your computer and use it in GitHub Desktop.
DFLib Sample ( DataFrame implements Java)
a b c d
-- -- -- --
4 5 6 a
40 41 42 a
46 47 48 a
52 53 54 b
58 59 60 b
64 65 66 c
94 95 96 c
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS org.dflib:dflib:1.3.0
//DEPS org.dflib:dflib-csv:1.3.0
//FILES data.tsv
//FILES type.tsv
//JAVA 25+
import org.apache.commons.csv.CSVFormat;
import org.dflib.DataFrame;
import org.dflib.Printers;
import org.dflib.csv.Csv;
void main(String... args) {
CSVFormat csvFormat = CSVFormat.Builder.create().setDelimiter("\t").build();
DataFrame dataFrame = Csv.loader().format(csvFormat).header("a","b","c","d").intCol("c").offset(2).load("data.tsv").sort("c",false);
DataFrame dataFrameType = Csv.loader().format(csvFormat).header("type", "name").offset(2).load("type.tsv");
DataFrame selectFrame = dataFrame.innerJoin(dataFrameType).on("d", "type").select();
IO.println(Printers.tabular(100,100).toString(selectFrame.cols("a","b","c","name").select()));
}
type name
-- --
a TypeA
b TypeB
c TypeC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment