In [1]:
%%classpath add mvn
tech.tablesaw tablesaw-beakerx 0.36.0
com.jimmoores quandl-tablesaw 2.0.0
In [4]:
import tech.tablesaw.aggregate.AggregateFunctions.*
import tech.tablesaw.api.*
import tech.tablesaw.columns.*
Out[4]:
Comments¶
Tablesaw's usability is still far away from Python pandas or Spark DataFrame (even though it is the best implementation for JVM currently). I suggest you stick to Spark DataFrame or Python pandas at this time.
You can display Tablesaw tables with BeakerX table display widget by running the following command.
tech.tablesaw.beakerx.TablesawDisplayer.register()
Column¶
In [6]:
val numbers = arrayOf(1, 2, 3, 4)
val col = DoubleColumn.create("nc", numbers)
println(col.print())
Out[6]:
In [7]:
col.get(2)
Out[7]:
In [10]:
col.multiply(4)
Out[10]:
In [11]:
println(col.multiply(4).print())
Out[11]:
In [13]:
col.isLessThan(3.0)
Out[13]:
In [16]:
val c = col.isLessThan(3.0)
c
Out[16]:
In [18]:
println(col.where(c).print())
Out[18]:
In [20]:
col.where(col.isLessThan(3.0).and(col.isPositive()))
Out[20]:
In [21]:
println(col.where(col.isLessThan(3.0).and(col.isPositive())).print())
Out[21]:
In [22]:
col.where(Selection.with(0, 2))
In [ ]:
col.where(Selection.withRange(1, 3))
Table/DataFrame¶
In [6]:
val flights = Table.read().csv("../../home/media/data/flights14.csv")
Out[6]:
In [5]:
flights.structure()
In [6]:
flights.columnNames()
Out[6]:
In [7]:
flights.shape()
Out[7]:
In [9]:
flights.first(10)
In [10]:
flights.summary()
Out[10]:
In [8]:
val values = doubleArrayOf(1.0, 2.0, 3.0, 7.0, 9.44242, 11.0)
values
Out[8]:
In [9]:
val column = DoubleColumn.create("my_numbers", values)
Out[9]:
In [11]:
DoubleColumn.create("col", 0.until(10).map{
i -> i.toDouble()
})
In [5]:
import tech.tablesaw.api.Table
import tech.tablesaw.api.DoubleColumn
val table = Table.create("Table1")
for (i in 0.until(10)) {
val column = DoubleColumn.create("column_" + i, 0.until(10).map{
j -> (j + 10 * i).toDouble()
})
table.addColumns(column)
}
table.print()
Out[5]:
References¶
https://github.com/jtablesaw/tablesaw
https://jtablesaw.github.io/tablesaw/gettingstarted
https://jtablesaw.wordpress.com/
https://javadoc.io/doc/tech.tablesaw/tablesaw-core/0.25.2/tech/tablesaw/api/Table.html
https://javadoc.io/doc/tech.tablesaw/tablesaw-core/0.25.2/tech/tablesaw/api/DoubleColumn.html
In [ ]: