@@ -6,12 +6,14 @@ import kotlinx.datetime.LocalDateTime
6
6
import kotlinx.datetime.LocalTime
7
7
import kotlinx.datetime.TimeZone
8
8
import kotlinx.datetime.toLocalDateTime
9
+ import org.jetbrains.kotlinx.dataframe.AnyBaseCol
9
10
import org.jetbrains.kotlinx.dataframe.AnyCol
10
11
import org.jetbrains.kotlinx.dataframe.AnyFrame
11
12
import org.jetbrains.kotlinx.dataframe.ColumnsContainer
12
13
import org.jetbrains.kotlinx.dataframe.ColumnsSelector
13
14
import org.jetbrains.kotlinx.dataframe.DataColumn
14
15
import org.jetbrains.kotlinx.dataframe.DataFrame
16
+ import org.jetbrains.kotlinx.dataframe.DataFrameExpression
15
17
import org.jetbrains.kotlinx.dataframe.DataRow
16
18
import org.jetbrains.kotlinx.dataframe.RowColumnExpression
17
19
import org.jetbrains.kotlinx.dataframe.RowValueExpression
@@ -46,6 +48,8 @@ import org.jetbrains.kotlinx.dataframe.impl.api.withRowCellImpl
46
48
import org.jetbrains.kotlinx.dataframe.impl.headPlusArray
47
49
import org.jetbrains.kotlinx.dataframe.impl.io.FastDoubleParser
48
50
import org.jetbrains.kotlinx.dataframe.io.toDataFrame
51
+ import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO
52
+ import org.jetbrains.kotlinx.dataframe.util.CONVERT_TO_REPLACE
49
53
import java.math.BigDecimal
50
54
import java.math.BigInteger
51
55
import java.net.URL
@@ -79,8 +83,7 @@ internal interface SeeAlsoParse
79
83
* Additionally, it offers a wide range of methods for converting to specific types,
80
84
* such as [toStr][Convert.toStr], [toDouble][Convert.toDouble], and many others.
81
85
*
82
- * For the full list of supported types,
83
- * refer to the [documentation website]({@include [DocumentationUrls.Url]}/convert.html).
86
+ * For the full list of supported types, see [SupportedTypes].
84
87
*
85
88
* Each method returns a new [DataFrame] with the updated columns.
86
89
*
@@ -102,6 +105,18 @@ internal interface ConvertDocs {
102
105
*/
103
106
interface ConvertSelectingOptions
104
107
108
+ /* *
109
+ * List of types, supported in [convert to][Convert.to] operation:
110
+ * * [String] (uses parse to convert from String to other types);
111
+ * * [Boolean];
112
+ * * [Byte], [Short], [Char];
113
+ * * [Int], [Long], [Float], [Double];
114
+ * * [BigDecimal], [BigInteger];
115
+ * * [LocalDateTime], [LocalDate], [LocalTime], [Instant] ( (kotlinx.datetime and [java.time]),
116
+ * * [URL], [IMG], [IFRAME].
117
+ */
118
+ interface SupportedTypes
119
+
105
120
/* *
106
121
* ## Convert Operation Grammar
107
122
* {@include [LineBreak]}
@@ -123,9 +138,6 @@ internal interface ConvertDocs {
123
138
* `| `__`.`__[**`to`**][Convert.to]`(type: `[`KType`][KType]`)`
124
139
*
125
140
* {@include [Indent]}
126
- * `| `__`.`__[**`to`**][Convert.to]` { columnConverter: `[`DataFrame`](DataFrame)`.(`[`DataColumn`](DataColumn)`) -> `[`AnyBaseColumn`](AnyBaseColumn)` }`
127
- *
128
- * {@include [Indent]}
129
141
* `| `__`.`__[**`perRowCol`**][Convert.perRowCol]` { expression: `[`RowColumnExpression`][RowColumnExpression]` }`
130
142
*
131
143
* {@include [Indent]}
@@ -293,7 +305,7 @@ public inline fun <T, C, reified R> Convert<T, C?>.notNull(
293
305
*
294
306
* Use the following methods to perform the conversion:
295
307
* - [to(kType)][to]/[to`<Type`>()][to] – converts columns to a specific type.
296
- * - [to { columnConverter }][to ] - converts columns using column converter expression.
308
+ * - [asColumn { columnConverter }][asColumn ] - converts columns using column converter expression.
297
309
* - [with][Convert.with] – applies a custom row-wise conversion expression.
298
310
* - [notNull][Convert.notNull] – like [with], but only for non-null values.
299
311
* - [perRowCol][Convert.perRowCol] – applies a conversion that uses both column and row information.
@@ -324,8 +336,7 @@ public class Convert<T, out C>(
324
336
* preserving their original names and positions within the [DataFrame].
325
337
*
326
338
* The target type is provided as a reified type argument.
327
- * For the full list of supported types,
328
- * refer to the [documentation website]({@include [DocumentationUrls.Url]}/convert.html).
339
+ * For the full list of supported types, see [ConvertDocs.SupportedTypes].
329
340
*
330
341
* For more information: {@include [DocumentationUrls.Convert]}
331
342
*
@@ -353,8 +364,7 @@ public class Convert<T, out C>(
353
364
* preserving their original names and positions within the [DataFrame].
354
365
*
355
366
* The target type is provided as a [KType].
356
- * For the full list of supported types,
357
- * refer to the [documentation website]({@include [DocumentationUrls.Url]}/convert.html).
367
+ * For the full list of supported types, see [ConvertDocs.SupportedTypes].
358
368
*
359
369
* For more information: {@include [DocumentationUrls.Convert]}
360
370
*
@@ -372,6 +382,10 @@ public class Convert<T, out C>(
372
382
*/
373
383
public fun <T > Convert <T , * >.to (type : KType ): DataFrame <T > = asColumn { it.convertTo(type) }
374
384
385
+ @Deprecated(CONVERT_TO , ReplaceWith (CONVERT_TO_REPLACE ), DeprecationLevel .ERROR )
386
+ public fun <T , C > Convert <T , C >.to (columnConverter : DataFrame <T >.(DataColumn <C >) -> AnyBaseCol ): DataFrame <T > =
387
+ df.replace(columns).with { columnConverter(df, it) }
388
+
375
389
/* * [Convert per row col][Convert.perRowCol] to provide a new value for every selected cell giving its column. */
376
390
@ExcludeFromSources
377
391
private interface SeeAlsoConvertPerRowCol
@@ -512,8 +526,7 @@ public inline fun <T, C, reified R> Convert<T, C>.perRowCol(
512
526
*
513
527
* The target type is provided as a reified type argument.
514
528
*
515
- * For the full list of supported types,
516
- * refer to the [documentation website]({@include [DocumentationUrls.Url]}/convert.html).
529
+ * For the full list of supported types, see [ConvertDocs.SupportedTypes].
517
530
*
518
531
* @param [C] The target type to convert values to.
519
532
* @return A new [DataColumn] with the values converted to type [C].
@@ -523,8 +536,7 @@ public inline fun <reified C> AnyCol.convertTo(): DataColumn<C> = convertTo(type
523
536
/* *
524
537
* Converts values in this column to the specified [type].
525
538
*
526
- * For the full list of supported types,
527
- * refer to the [documentation website]({@include [DocumentationUrls.Url]}/convert.html).
539
+ * For the full list of supported types, see [ConvertDocs.SupportedTypes].
528
540
*
529
541
* @param type The target type, provided as a [KType], to convert values to.
530
542
* @return A new [DataColumn] with the values converted to [type].
0 commit comments