Introduction
Our hero today is a new java library called Fahmatrix.
Fahmatrix is a lightweight, modern Java library for working with tabular data, inspired by Python's Pandas and rooted in the idea of making data understanding (fahm) easy on the JVM.
you can find it on Github
Step 1 (installation)
- Goto releases page and download the jar file.
- I use Eclipse.
- Add jar file to ./libs folder.
- Right click on project from Eclipse IDE.
- choose Java Build Path.
- Add Extrenal Java File.
- Choose the file ./libs/fahmatrix-vxxx.jar
Step 2 (import data)
- create class SimpleCSV.java
- add the following code.
-
replace path//to//data.csv with your actual data file path
import com.fahmatrix.DataFrame; import com.fahmatrix.Series; public class SimpleCSV { public static void main(String[] args) { DataFrame df = new DataFrame(); df.readCSV("path//to//data.csv"); } }
Step 3 (select data)
// select rows by position
DataFrame result = df.getRowsByPosition(new int[]{1,2,3,4,5,10,11,12,13,14,15});
// select columns by name
result = result.getColumnsByLabel(new String[]{"name","address","city"});
now you have only the needed data.
Step 4 (view data in console)
just call print()
result.print();
Final Thoughts
Fahmatrix is a new java library to make data operations easy. i hope it continues development as we want.
Top comments (0)