Package

com.github.marklister

collections

Permalink

package collections

A strongly typed tabular data framework.

collections.CollSeq is an IndexedSeq[Product] that also implements Product itself.

Specialized versions of CollSeq exist for arities 1 to 22. Each is an IndexedSeq[ProductN] and also implements ProductN

In action
import com.github.marklister.collections.io._
 import com.github.marklister.collections._
 Welcome to Scala version 2.10.1 (OpenJDK Server VM, Java 1.7.0_21).
 Type in expressions to have them evaluated.
 Type :help for more information.

 scala> CollSeq(("Jan",10,20),("Feb",33,44),("Mar",77,33))
 res0: com.github.marklister.collections.immutable.CollSeq3[String,Int,Int] =
 CollSeq((Jan,10,20),
         (Feb,33,44),
         (Mar,77,33))

 scala> //Extract column one

 scala> res0._1
 res1: Seq[String] = List(Jan, Feb, Mar)

 scala> //Join Column one and column 3 as a new collection:

 scala> res0._1 flatZip res0._3
 res2: com.github.marklister.collections.immutable.CollSeq2[String,Int] =
 CollSeq((Jan,20),
         (Feb,44),
         (Mar,33))
I/O

io.CsvParser is a very easy way to read CollSeqs or Tuples from the File System.

You use the factory to select a parser:

val parser= CsvParser[String, Int, Double]

and read your file like this:

val data= parser.parseFile("example.csv")

You wind up with CollSeq3[String,Int,Double]

Positioning

product-collections aims to be simple and productive: you should be producing answers from your data in 20 minutes or less. There is no new api to learn -- everything works like a scala collection and a Tuple at the same time. There's no matrix arithmetic: do everything in idomatic scala.

Columns don't lose their type if you include a column of another type. ' Learn by example: take a look (or clone) the simple example project on Gitub that does some simple processing of stock prices.

Alternatives
Saddle

A heavy duty solution. Custom api based around Vectors Matrixes and Scalars. Trying to mix types in a Saddle matrix results in a Matrix[Any] which means not much type safety. Saddle seems to have garnered some support from Typesafe and may feature in GSOC.

Saddle has heavy emphasis on specialization and (presumably) performance.

Breeze

Breeze also has matrix and vector implementations similar to Saddle. Also some other stuff that looks pretty useful.

Framian

Under heavy development this looks interesting. It does look more complicated than p-c. One specifies the return type at retrieval time.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. collections
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type CollSeq = collections.immutable.CollSeq

    Permalink
  2. type CollSeq1[T1] = collections.immutable.CollSeq1[T1]

    Permalink
  3. type CollSeq10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10] = collections.immutable.CollSeq10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]

    Permalink
  4. type CollSeq11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11] = collections.immutable.CollSeq11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]

    Permalink
  5. type CollSeq12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12] = collections.immutable.CollSeq12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]

    Permalink
  6. type CollSeq13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13] = collections.immutable.CollSeq13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]

    Permalink
  7. type CollSeq14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14] = collections.immutable.CollSeq14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]

    Permalink
  8. type CollSeq15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15] = collections.immutable.CollSeq15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]

    Permalink
  9. type CollSeq16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16] = collections.immutable.CollSeq16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]

    Permalink
  10. type CollSeq17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17] = collections.immutable.CollSeq17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]

    Permalink
  11. type CollSeq18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18] = collections.immutable.CollSeq18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]

    Permalink
  12. type CollSeq19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19] = collections.immutable.CollSeq19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]

    Permalink
  13. type CollSeq2[T1, T2] = collections.immutable.CollSeq2[T1, T2]

    Permalink
  14. type CollSeq20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20] = collections.immutable.CollSeq20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]

    Permalink
  15. type CollSeq21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21] = collections.immutable.CollSeq21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]

    Permalink
  16. type CollSeq22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22] = collections.immutable.CollSeq22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]

    Permalink
  17. type CollSeq3[T1, T2, T3] = collections.immutable.CollSeq3[T1, T2, T3]

    Permalink
  18. type CollSeq4[T1, T2, T3, T4] = collections.immutable.CollSeq4[T1, T2, T3, T4]

    Permalink
  19. type CollSeq5[T1, T2, T3, T4, T5] = collections.immutable.CollSeq5[T1, T2, T3, T4, T5]

    Permalink
  20. type CollSeq6[T1, T2, T3, T4, T5, T6] = collections.immutable.CollSeq6[T1, T2, T3, T4, T5, T6]

    Permalink
  21. type CollSeq7[T1, T2, T3, T4, T5, T6, T7] = collections.immutable.CollSeq7[T1, T2, T3, T4, T5, T6, T7]

    Permalink
  22. type CollSeq8[T1, T2, T3, T4, T5, T6, T7, T8] = collections.immutable.CollSeq8[T1, T2, T3, T4, T5, T6, T7, T8]

    Permalink
  23. type CollSeq9[T1, T2, T3, T4, T5, T6, T7, T8, T9] = collections.immutable.CollSeq9[T1, T2, T3, T4, T5, T6, T7, T8, T9]

    Permalink

Value Members

  1. val CollSeq: collections.immutable.CollSeq.type

    Permalink
  2. val CollSeq1: collections.immutable.CollSeq1.type

    Permalink
  3. val CollSeq10: collections.immutable.CollSeq10.type

    Permalink
  4. val CollSeq11: collections.immutable.CollSeq11.type

    Permalink
  5. val CollSeq12: collections.immutable.CollSeq12.type

    Permalink
  6. val CollSeq13: collections.immutable.CollSeq13.type

    Permalink
  7. val CollSeq14: collections.immutable.CollSeq14.type

    Permalink
  8. val CollSeq15: collections.immutable.CollSeq15.type

    Permalink
  9. val CollSeq16: collections.immutable.CollSeq16.type

    Permalink
  10. val CollSeq17: collections.immutable.CollSeq17.type

    Permalink
  11. val CollSeq18: collections.immutable.CollSeq18.type

    Permalink
  12. val CollSeq19: collections.immutable.CollSeq19.type

    Permalink
  13. val CollSeq2: collections.immutable.CollSeq2.type

    Permalink
  14. val CollSeq20: collections.immutable.CollSeq20.type

    Permalink
  15. val CollSeq21: collections.immutable.CollSeq21.type

    Permalink
  16. val CollSeq22: collections.immutable.CollSeq22.type

    Permalink
  17. val CollSeq3: collections.immutable.CollSeq3.type

    Permalink
  18. val CollSeq4: collections.immutable.CollSeq4.type

    Permalink
  19. val CollSeq5: collections.immutable.CollSeq5.type

    Permalink
  20. val CollSeq6: collections.immutable.CollSeq6.type

    Permalink
  21. val CollSeq7: collections.immutable.CollSeq7.type

    Permalink
  22. val CollSeq8: collections.immutable.CollSeq8.type

    Permalink
  23. val CollSeq9: collections.immutable.CollSeq9.type

    Permalink
  24. implicit def SeqABToWeightedStatsAB[A, B](s: Iterable[Product2[A, B]])(implicit numA: Numeric[A], numB: Numeric[B]): WeightedStats[A, B]

    Permalink

    Convert a Seq[(Numeric,Numeric)] to a WeightedStats object

  25. implicit def SeqAToStatsA[A](s: Iterable[A])(implicit num: Numeric[A]): Stats[A]

    Permalink

    Convert a Seq[Numeric] to a Stats object

  26. implicit def SeqToCollSeqTa[T](s: Seq[Product1[T]]): CollSeq1[T]

    Permalink

    Convert a Seq[Product1] to a CollSeq1

  27. implicit def SeqToCollSeqTb[Ta, Tb](s: Seq[Product2[Ta, Tb]]): CollSeq2[Ta, Tb]

    Permalink

    Convert a Seq[Product2] to a CollSeq2

  28. implicit def SeqToCollSeqTc[T](s: Seq[T]): CollSeq1[T]

    Permalink

    Convert a Seq[Any] to a CollSeq

  29. package immutable

    Permalink

    At the moment the only structure available is a CollSeq

    Immutable product-collection datastructures

    At the moment the only structure available is a CollSeq

    Creating

    Generally you use the companion object to construct the appropriate CollSeq:

    scala> CollSeq(("Jan",100,200),("Feb",120,230),("Mar",300,330))
    res0: com.github.marklister.collections.immutable.CollSeq3[String,Int,Int] =
    CollSeq((Jan,100,200),
            (Feb,120,230),
            (Mar,300,330))
    Extract a column
    scala> res0._2
    res1: Seq[Int] = List(100, 120, 300)
    Assemble columns into a CollSeq
    scala> res0._3.flatZip(res0._1).flatZip(res0._2)
    res3: com.github.marklister.collections.immutable.CollSeq3[Int,String,Int] =
    CollSeq((200,Jan,100),
            (230,Feb,120),
            (330,Mar,300))
  30. package io

    Permalink
  31. package util

    Permalink

    Implicit conversions in package object com.github.marklister.collections make the following promotions available:

    Statistics Classes

    Implicit conversions in package object com.github.marklister.collections make the following promotions available:

    - Seq[Numeric] => Stats[Numeric] - Seq[(Numeric,Numeric)] => WeightedStats[Numeric,Numeric]

    The classes com.github.marklister.collections.util.Stats and com.github.marklister.collections.util.WeightedStats make methods like mean, variance, and stdDev available.

    Example
    import com.github.marklister.collections.io._
    import com.github.marklister.collections._
    Welcome to Scala version 2.10.1 (OpenJDK Server VM, Java 1.7.0_21).
    Type in expressions to have them evaluated.
    Type :help for more information.
    
    scala> Seq(1,2,3).mean
    res0: Double = 2.0
    
    scala> CollSeq((1,2),(2,1),(3,3)).mean
    res1: Double = 2.1666666666666665
    
    scala> (2.0+2.0+9.0)/6.0
    res2: Double = 2.1666666666666665

Inherited from AnyRef

Inherited from Any

Ungrouped