com.github.marklister

collections

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
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. type CollSeq = collections.immutable.CollSeq

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

  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]

  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]

  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]

  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]

  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]

  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]

  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]

  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]

  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]

  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]

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

  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]

  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]

  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]

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

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

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

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

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

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

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

Value Members

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Convert a Seq[Numeric] to a Stats object

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

    Convert a Seq[Product1] to a CollSeq1

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

    Convert a Seq[Product2] to a CollSeq2

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

    Convert a Seq[Any] to a CollSeq

  29. package immutable

    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

  31. package util

    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