1
1
package org.jetbrains.kotlinx.dataframe.api
2
2
3
3
import io.kotest.matchers.shouldBe
4
- import org.jetbrains.kotlinx.dataframe.ncol
5
- import org.jetbrains.kotlinx.dataframe.nrow
6
4
import org.junit.Test
7
5
import kotlin.reflect.typeOf
8
6
@@ -18,7 +16,7 @@ class PivotTests {
18
16
fun `simple pivot` () {
19
17
val pivoted = df.pivot(b, inward = false ).groupBy(a).values(c)
20
18
pivoted.columnNames() shouldBe listOf (" a" , " q" , " w" )
21
- pivoted.nrow shouldBe 2
19
+ pivoted.rowsCount() shouldBe 2
22
20
pivoted[" q" ].values() shouldBe listOf (' x' , ' y' )
23
21
pivoted[" w" ].values() shouldBe listOf (null , ' z' )
24
22
}
@@ -27,7 +25,7 @@ class PivotTests {
27
25
fun `pivot with rename` () {
28
26
val pivoted = df.pivot(b).groupBy(a).values { c default ' ?' into " d" and (c into " e" ) }
29
27
pivoted.columnNames() shouldBe listOf (" a" , " b" )
30
- pivoted.nrow shouldBe 2
28
+ pivoted.rowsCount() shouldBe 2
31
29
32
30
pivoted[" b" ][" q" ][" d" ].values() shouldBe listOf (' x' , ' y' )
33
31
pivoted[" b" ][" q" ][" e" ].values() shouldBe listOf (' x' , ' y' )
@@ -41,8 +39,8 @@ class PivotTests {
41
39
get(c).first() default ' -' into " first"
42
40
get(c).last() into " last" default ' ?'
43
41
}
44
- pivoted.ncol shouldBe 3
45
- pivoted.nrow shouldBe 2
42
+ pivoted.columnsCount() shouldBe 3
43
+ pivoted.rowsCount() shouldBe 2
46
44
val cols = pivoted.getColumns { except(a).allDfs() }
47
45
cols.size shouldBe 4
48
46
cols.forEach {
@@ -127,7 +125,7 @@ class PivotTests {
127
125
df.pivot(" a" ).minBy(" b" ).values(" c" , " d" , separate = true ) shouldBe
128
126
dataFrameOf(" c1" , " c2" , " d1" , " d2" )(
129
127
2 , 3 , 4 , 2
130
- ).move { all() }.into { pathOf(it.name[0 ].toString(), it.name[1 ].toString()) }[0 ]
128
+ ).move { all() }.into { pathOf(it.name() [0 ].toString(), it.name() [1 ].toString()) }[0 ]
131
129
}
132
130
133
131
@Test
0 commit comments