Package com.fahmatrix
Class DataFrame
java.lang.Object
com.fahmatrix.DataFrame
DataFrame is the basic object for hadling data
Current Features:
Select/Add column data
Print in System Console
Print data Summary
Import From CSV/TSV, xlsx
Reverse (transpose) data
Select Row/Column by Label or Position
Current Features:
Select/Add column data
Print in System Console
Print data Summary
Import From CSV/TSV, xlsx
Reverse (transpose) data
Select Row/Column by Label or Position
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add column to the end of data tablevoid
describe()
Pretty Print Data Summary in System ConsolegetByLabel
(String rowLabel, String colLabel) Select Cell by row and column namegetByLabels
(String[] rowLabels, String[] colLabels) Select certains rows and columns by name
these names are not Excel A1,B1 names.getByPosition
(int rowIdx, int colIdx) Select Cell by row and column positionsgetByPositions
(int[] rowIndices, int[] colIndices) Select certains rows and columns by positionreturn a new Series Object with data of only one columngetColumnsByLabel
(String... columnLabels) Select Columns by name
this method assumes you selected all rowsgetColumnsByPosition
(int... columnIndices) Select certains columns positiongetRowsByLabel
(String... rowLabels) Select Rows by name
this method assumes you selected all columnsgetRowsByPosition
(int... rowIndices) Select certains rows positionhead()
Return the first 5 rows as DataFrame Objecthead
(int n) Return the first n rows as DataFrame Objectvoid
print()
Pretty Print in System ConsoleRead , Parse and save the CSV file
Make sure the file is found before calling.Read , Parse and save the Microsoft Excel SpreadSheet xlsx file
Make sure the file is found before calling.com.fahmatrix.Helpers.DataSelector
select()
Select using builder pattern
use like that example
select().rows(new int[]{1,2,3}).columns(new int[]{1,2,3}).get()
or
select().rows(new String[]{"row1","row2","row3"}).columns(new String[]{"column1","column2","column3"}).get()tail()
Return the last 5 rows as DataFrame Objecttail
(int n) Return the last n rows as DataFrame ObjectReverse Rows and Columns
-
Constructor Details
-
DataFrame
public DataFrame()Constructor with empty indexes and columns -
DataFrame
Constructor with known indexes and empty columns- Parameters:
index
- Array of indexes
-
DataFrame
Constructor with known indexes and columns- Parameters:
index
- Array of indexescolumns
- Map of data where key is the column name and the value is Array of cells data
-
-
Method Details
-
addColumn
Add column to the end of data table- Parameters:
name
- index namedata
- column data (Array of cells data)
-
getColumn
return a new Series Object with data of only one column- Parameters:
name
- column name- Returns:
- Series data with index
-
getColumnsByLabel
Select Columns by name
this method assumes you selected all rows- Parameters:
columnLabels
- Basic String Array (String[]) for column names- Returns:
- New Dataframe with only the selected data
-
getColumnsByPosition
Select certains columns position- Parameters:
columnIndices
- Basic Integer Array (int[]) for columns position- Returns:
- New Dataframe with only the selected datas
-
head
Return the first 5 rows as DataFrame Object- Returns:
- first 5 rows
-
head
Return the first n rows as DataFrame Object- Parameters:
n
- the max number of rows to return- Returns:
- rows
-
tail
Return the last 5 rows as DataFrame Object- Returns:
- last 5 rows
-
tail
Return the last n rows as DataFrame Object- Parameters:
n
- the max number of rows to return- Returns:
- rows
-
transpose
Reverse Rows and Columns- Returns:
- new DataFrame with transposed data
-
getByLabel
Select Cell by row and column name- Parameters:
rowLabel
- row namecolLabel
- column name- Returns:
- Object for cell value (String, Float, Double)
-
getRowsByLabel
Select Rows by name
this method assumes you selected all columns- Parameters:
rowLabels
- Basic String Array (String[]) for rows name- Returns:
- New Dataframe with only the selected data
-
getByLabels
Select certains rows and columns by name
these names are not Excel A1,B1 names.- Parameters:
rowLabels
- Basic String Array (String[]) for row namescolLabels
- Basic String Array (String[]) for column names- Returns:
- New Dataframe with only the selected data
-
getByPosition
Select Cell by row and column positions- Parameters:
rowIdx
- row positioncolIdx
- column position- Returns:
- Object for cell value (String, Float, Double)
-
getRowsByPosition
Select certains rows position- Parameters:
rowIndices
- Basic Integer Array (int[]) for row positions- Returns:
- New Dataframe with only the selected data
-
getByPositions
Select certains rows and columns by position- Parameters:
rowIndices
- Basic Integer Array (int[]) for row positionscolIndices
- Basic Integer Array (int[]) for column positions- Returns:
- New Dataframe with only the selected data
-
select
public com.fahmatrix.Helpers.DataSelector select()Select using builder pattern
use like that example
select().rows(new int[]{1,2,3}).columns(new int[]{1,2,3}).get()
or
select().rows(new String[]{"row1","row2","row3"}).columns(new String[]{"column1","column2","column3"}).get()- Returns:
- Selection Builder Object
-
print
public void print()Pretty Print in System Console -
describe
public void describe()Pretty Print Data Summary in System Console -
readCSV
Read , Parse and save the CSV file
Make sure the file is found before calling. And it has a proper CSV/TSV format
All data are saved in the same object no need to create a new one
Note: it replace any old data
- Parameters:
filePath
- CSV file path- Returns:
- the same object after saving data (this) if successful
-
readXlsx
Read , Parse and save the Microsoft Excel SpreadSheet xlsx file
Make sure the file is found before calling.
All data are saved in the same object no need to create a new one
Note: it replace any old data
- Parameters:
filePath
- xlsx file path- Returns:
- the same object after saving data (this) if successful
-