Skip to content

Commit

Permalink
addressed comments v3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
brkyvz committed May 3, 2015
1 parent a0cad97 commit a63ad00
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,22 @@ class DataFrameStatSuite extends FunSuite {
def toLetter(i: Int): String = (i + 97).toChar.toString

test("crosstab") {
val df = sqlCtx.sparkContext.parallelize((1 to 6).map(i => (i % 3, i % 2))).toDF("a", "b")
val df = Seq.tabulate(8)(i => (i % 3, i % 2)).toDF("a", "b")
val crosstab = df.stat.crosstab("a", "b")
val columnNames = crosstab.schema.fieldNames
assert(columnNames(0) === "a_b")
assert(columnNames(1) === "0")
assert(columnNames(2) === "1")
val rows: Array[Row] = crosstab.collect()
var count: Integer = 0
rows.foreach { row =>
assert(row.get(0).toString === count.toString)
assert(row.getLong(1) === 1L)
assert(row.getLong(2) === 1L)
count += 1
}
assert(rows(0).get(0).toString === "0")
assert(rows(0).getLong(1) === 2L)
assert(rows(0).getLong(2) === 1L)
assert(rows(1).get(0).toString === "1")
assert(rows(1).getLong(1) === 1L)
assert(rows(1).getLong(2) === 2L)
assert(rows(2).get(0).toString === "2")
assert(rows(2).getLong(1) === 1L)
assert(rows(2).getLong(2) === 1L)
}

test("Frequent Items") {
Expand Down

0 comments on commit a63ad00

Please sign in to comment.