File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
core/src/main/kotlin/org/jetbrains/kotlinx/dataframe Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -102,9 +102,11 @@ public interface DataFrame<out T> :
102102 @RequiredByIntellijPlugin
103103 public operator fun get (index : Int ): DataRow <T >
104104
105- public operator fun get (indices : Iterable <Int >): DataFrame <T > = getRows(indices)
105+ public operator fun get (indices : Iterable <Int >): DataFrame <T > =
106+ columns().map { col -> col[indices] }.toDataFrame().cast()
106107
107- public operator fun get (range : IntRange ): DataFrame <T > = getRows(range)
108+ public operator fun get (range : IntRange ): DataFrame <T > =
109+ if (range == indices()) this else columns().map { col -> col[range] }.toDataFrame().cast()
108110
109111 public operator fun get (first : IntRange , vararg ranges : IntRange ): DataFrame <T > =
110112 getRows(headPlusArray(first, ranges).asSequence().flatMap { it.asSequence() }.asIterable())
Original file line number Diff line number Diff line change @@ -45,11 +45,9 @@ public fun <T> DataFrame<T>.getColumns(vararg columns: String): List<AnyCol> = g
4545
4646public fun <T > DataFrame<T>.getColumnIndex (col : AnyCol ): Int = getColumnIndex(col.name())
4747
48- public fun <T > DataFrame<T>.getRows (range : IntRange ): DataFrame <T > =
49- if (range == indices()) this else columns().map { col -> col[range] }.toDataFrame().cast()
48+ public fun <T > DataFrame<T>.getRows (range : IntRange ): DataFrame <T > = get(range)
5049
51- public fun <T > DataFrame<T>.getRows (indices : Iterable <Int >): DataFrame <T > =
52- columns().map { col -> col[indices] }.toDataFrame().cast()
50+ public fun <T > DataFrame<T>.getRows (indices : Iterable <Int >): DataFrame <T > = get(indices)
5351
5452public fun <T > DataFrame<T>.getOrNull (index : Int ): DataRow <T >? = if (index < 0 || index >= nrow) null else get(index)
5553
You can’t perform that action at this time.
0 commit comments