init research
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
# Utility functions
|
||||
|
||||
|
||||
<web-summary>
|
||||
Overview of common utility operations in Kotlin Dataframe.
|
||||
</web-summary>
|
||||
|
||||
<card-summary>
|
||||
Overview of common utility operations in Kotlin Dataframe.
|
||||
</card-summary>
|
||||
|
||||
<link-summary>
|
||||
Overview of common utility operations in Kotlin Dataframe.
|
||||
</link-summary>
|
||||
|
||||
Explore frequently used helpers for querying and transforming your data:
|
||||
|
||||
- [`all`](all.md) — Check whether all rows satisfy a predicate.
|
||||
- [`any`](any.md) — Check whether any row satisfies a predicate.
|
||||
- [`chunked`](chunked.md) — Split a [`DataFrame`](DataFrame.md) into consecutive chunks and return them as a
|
||||
[`FrameColumn`](DataColumn.md#framecolumn).
|
||||
- [`shuffle`](shuffle.md) — Randomly reorder rows.
|
||||
@@ -0,0 +1,70 @@
|
||||
# all
|
||||
|
||||
|
||||
<web-summary>
|
||||
Discover `all` operation in Kotlin Dataframe.
|
||||
</web-summary>
|
||||
|
||||
<card-summary>
|
||||
Discover `all` operation in Kotlin Dataframe.
|
||||
</card-summary>
|
||||
|
||||
<link-summary>
|
||||
Discover `all` operation in Kotlin Dataframe.
|
||||
</link-summary>
|
||||
|
||||
<!---IMPORT org.jetbrains.kotlinx.dataframe.samples.api.utils.AllSamples-->
|
||||
|
||||
Checks if all rows in the [](DataFrame.md) satisfy the predicate.
|
||||
|
||||
Returns `Boolean` — `true` if every row satisfies the predicate, `false` otherwise.
|
||||
|
||||
```kotlin
|
||||
all { rowCondition }
|
||||
|
||||
rowCondition: (DataRow) -> Boolean
|
||||
```
|
||||
|
||||
**Related operations**: [](any.md), [](filter.md), [](single.md), [](count.md).
|
||||
|
||||
### Examples
|
||||
|
||||
<!---FUN notebook_test_all_3-->
|
||||
|
||||
```kotlin
|
||||
df
|
||||
```
|
||||
|
||||
<!---END-->
|
||||
|
||||
<inline-frame src="./resources/notebook_test_all_3.html" width="100%" height="500px"></inline-frame>
|
||||
|
||||
Check if all persons' `age` is greater than 21:
|
||||
|
||||
<!---FUN notebook_test_all_4-->
|
||||
|
||||
```kotlin
|
||||
df.all { age > 21 }
|
||||
```
|
||||
|
||||
<!---END-->
|
||||
|
||||
Output:
|
||||
```text
|
||||
false
|
||||
```
|
||||
|
||||
Check if all persons have `age` greater or equal to 15:
|
||||
|
||||
<!---FUN notebook_test_all_5-->
|
||||
|
||||
```kotlin
|
||||
df.all { name.first().isUpperCase() && age >= 15 }
|
||||
```
|
||||
|
||||
<!---END-->
|
||||
|
||||
Output:
|
||||
```text
|
||||
true
|
||||
```
|
||||
@@ -0,0 +1,70 @@
|
||||
# any
|
||||
|
||||
|
||||
<web-summary>
|
||||
Discover `any` operation in Kotlin Dataframe.
|
||||
</web-summary>
|
||||
|
||||
<card-summary>
|
||||
Discover `any` operation in Kotlin Dataframe.
|
||||
</card-summary>
|
||||
|
||||
<link-summary>
|
||||
Discover `any` operation in Kotlin Dataframe.
|
||||
</link-summary>
|
||||
|
||||
<!---IMPORT org.jetbrains.kotlinx.dataframe.samples.api.utils.AnySamples-->
|
||||
|
||||
Checks if there is at least one row in the [](DataFrame.md) that satisfies the predicate.
|
||||
|
||||
Returns `Boolean` — `true` if there is at least one row that satisfies the predicate, `false` otherwise.
|
||||
|
||||
```kotlin
|
||||
df.any { rowCondition }
|
||||
|
||||
rowCondition: (DataRow) -> Boolean
|
||||
```
|
||||
|
||||
**Related operations**: [](all.md), [](filter.md), [](single.md), [](count.md).
|
||||
|
||||
### Examples
|
||||
|
||||
<!---FUN notebook_test_any_3-->
|
||||
|
||||
```kotlin
|
||||
df
|
||||
```
|
||||
|
||||
<!---END-->
|
||||
|
||||
<inline-frame src="./resources/notebook_test_any_3.html" width="100%" height="500px"></inline-frame>
|
||||
|
||||
Check if any person `age` is greater than 21:
|
||||
|
||||
<!---FUN notebook_test_any_4-->
|
||||
|
||||
```kotlin
|
||||
df.any { age > 21 }
|
||||
```
|
||||
|
||||
<!---END-->
|
||||
|
||||
Output:
|
||||
```text
|
||||
false
|
||||
```
|
||||
|
||||
Check if there is any person with `age` equal to 15 and `name` equal to "Alice":
|
||||
|
||||
<!---FUN notebook_test_any_5-->
|
||||
|
||||
```kotlin
|
||||
df.any { age == 15 && name == "Alice" }
|
||||
```
|
||||
|
||||
<!---END-->
|
||||
|
||||
Output:
|
||||
```text
|
||||
true
|
||||
```
|
||||
@@ -0,0 +1,64 @@
|
||||
# chunked
|
||||
|
||||
|
||||
<web-summary>
|
||||
Discover `chunked` operation in Kotlin Dataframe.
|
||||
</web-summary>
|
||||
|
||||
<card-summary>
|
||||
Discover `chunked` operation in Kotlin Dataframe.
|
||||
</card-summary>
|
||||
|
||||
<link-summary>
|
||||
Discover `chunked` operation in Kotlin Dataframe.
|
||||
</link-summary>
|
||||
|
||||
<!---IMPORT org.jetbrains.kotlinx.dataframe.samples.api.utils.ChunkedSamples-->
|
||||
|
||||
Splits a [`DataFrame`](DataFrame.md) into consecutive sub-dataframes (chunks) and returns them as a
|
||||
[`FrameColumn`](DataColumn.md#framecolumn). Chunks are formed in order and do not overlap.
|
||||
|
||||
Each chunk contains at most the specified number of rows.
|
||||
The resulting `FrameColumn`’s name can be customized; by default, it is "groups."
|
||||
|
||||
`DataFrame` can be split into chunks in two ways:
|
||||
- By fixed size: split into chunks of up to the given size.
|
||||
- By start indices: split using custom zero-based start indices for each chunk; each chunk ends right before the next start index or the end of the DataFrame.
|
||||
|
||||
```kotlin
|
||||
df.chunked(size: Int, name: String)
|
||||
df.chunked(startIndices: List<Int>, name: String)
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
<!---FUN notebook_test_chunked_1-->
|
||||
|
||||
```kotlin
|
||||
df
|
||||
```
|
||||
|
||||
<!---END-->
|
||||
<inline-frame src="./resources/notebook_test_chunked_1.html" width="100%" height="500px"></inline-frame>
|
||||
|
||||
Fixed size chunks:
|
||||
<!---FUN notebook_test_chunked_2-->
|
||||
|
||||
```kotlin
|
||||
df.chunked(size = 2)
|
||||
```
|
||||
|
||||
<!---END-->
|
||||
|
||||
<inline-frame src="./resources/notebook_test_chunked_2.html" width="100%" height="500px"></inline-frame>
|
||||
|
||||
Custom start indices:
|
||||
<!---FUN notebook_test_chunked_3-->
|
||||
|
||||
```kotlin
|
||||
df.chunked(startIndices = listOf(0, 1, 3), name = "segments")
|
||||
```
|
||||
|
||||
<!---END-->
|
||||
|
||||
<inline-frame src="./resources/notebook_test_chunked_3.html" width="100%" height="500px"></inline-frame>
|
||||
@@ -0,0 +1,47 @@
|
||||
# shuffle
|
||||
|
||||
|
||||
<web-summary>
|
||||
Discover `shuffle` operation in Kotlin Dataframe.
|
||||
</web-summary>
|
||||
|
||||
<card-summary>
|
||||
Discover `shuffle` operation in Kotlin Dataframe.
|
||||
</card-summary>
|
||||
|
||||
<link-summary>
|
||||
Discover `shuffle` operation in Kotlin Dataframe.
|
||||
</link-summary>
|
||||
|
||||
<!---IMPORT org.jetbrains.kotlinx.dataframe.samples.api.utils.ShuffleSamples-->
|
||||
|
||||
Returns a new [`DataFrame`](DataFrame.md) with rows in random order.
|
||||
|
||||
You can supply a [kotlin.random.Random](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.random/-random/)
|
||||
instance with a fixed seed for reproducible results.
|
||||
|
||||
```Kotlin
|
||||
df.shuffle()
|
||||
df.shuffle(random: Random)
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
<!---FUN notebook_test_shuffle_1-->
|
||||
|
||||
```kotlin
|
||||
df
|
||||
```
|
||||
|
||||
<!---END-->
|
||||
<inline-frame src="./resources/notebook_test_shuffle_1.html" width="100%" height="500px"></inline-frame>
|
||||
|
||||
Deterministic shuffle using a fixed seed:
|
||||
<!---FUN notebook_test_shuffle_2-->
|
||||
|
||||
```kotlin
|
||||
df.shuffle(Random(42))
|
||||
```
|
||||
|
||||
<!---END-->
|
||||
<inline-frame src="./resources/notebook_test_shuffle_2.html" width="100%" height="500px"></inline-frame>
|
||||
Reference in New Issue
Block a user