@@ -6,12 +6,14 @@ import kotlinx.datetime.LocalDateTime
66import kotlinx.datetime.LocalTime
77import kotlinx.datetime.TimeZone
88import kotlinx.datetime.toLocalDateTime
9+ import org.jetbrains.kotlinx.dataframe.AnyBaseCol
910import org.jetbrains.kotlinx.dataframe.AnyCol
1011import org.jetbrains.kotlinx.dataframe.AnyFrame
1112import org.jetbrains.kotlinx.dataframe.ColumnsContainer
1213import org.jetbrains.kotlinx.dataframe.ColumnsSelector
1314import org.jetbrains.kotlinx.dataframe.DataColumn
1415import org.jetbrains.kotlinx.dataframe.DataFrame
16+ import org.jetbrains.kotlinx.dataframe.DataFrameExpression
1517import org.jetbrains.kotlinx.dataframe.DataRow
1618import org.jetbrains.kotlinx.dataframe.RowColumnExpression
1719import org.jetbrains.kotlinx.dataframe.RowValueExpression
@@ -46,6 +48,8 @@ import org.jetbrains.kotlinx.dataframe.impl.api.withRowCellImpl
4648import org.jetbrains.kotlinx.dataframe.impl.headPlusArray
4749import org.jetbrains.kotlinx.dataframe.impl.io.FastDoubleParser
4850import 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
4953import java.math.BigDecimal
5054import java.math.BigInteger
5155import java.net.URL
@@ -79,8 +83,7 @@ internal interface SeeAlsoParse
7983 * Additionally, it offers a wide range of methods for converting to specific types,
8084 * such as [toStr][Convert.toStr], [toDouble][Convert.toDouble], and many others.
8185 *
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].
8487 *
8588 * Each method returns a new [DataFrame] with the updated columns.
8689 *
@@ -102,6 +105,18 @@ internal interface ConvertDocs {
102105 */
103106 interface ConvertSelectingOptions
104107
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+
105120 /* *
106121 * ## Convert Operation Grammar
107122 * {@include [LineBreak]}
@@ -123,9 +138,6 @@ internal interface ConvertDocs {
123138 * `| `__`.`__[**`to`**][Convert.to]`(type: `[`KType`][KType]`)`
124139 *
125140 * {@include [Indent]}
126- * `| `__`.`__[**`to`**][Convert.to]` { columnConverter: `[`DataFrame`](DataFrame)`.(`[`DataColumn`](DataColumn)`) -> `[`AnyBaseColumn`](AnyBaseColumn)` }`
127- *
128- * {@include [Indent]}
129141 * `| `__`.`__[**`perRowCol`**][Convert.perRowCol]` { expression: `[`RowColumnExpression`][RowColumnExpression]` }`
130142 *
131143 * {@include [Indent]}
@@ -293,7 +305,7 @@ public inline fun <T, C, reified R> Convert<T, C?>.notNull(
293305 *
294306 * Use the following methods to perform the conversion:
295307 * - [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.
297309 * - [with][Convert.with] – applies a custom row-wise conversion expression.
298310 * - [notNull][Convert.notNull] – like [with], but only for non-null values.
299311 * - [perRowCol][Convert.perRowCol] – applies a conversion that uses both column and row information.
@@ -324,8 +336,7 @@ public class Convert<T, out C>(
324336 * preserving their original names and positions within the [DataFrame].
325337 *
326338 * 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].
329340 *
330341 * For more information: {@include [DocumentationUrls.Convert]}
331342 *
@@ -353,8 +364,7 @@ public class Convert<T, out C>(
353364 * preserving their original names and positions within the [DataFrame].
354365 *
355366 * 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].
358368 *
359369 * For more information: {@include [DocumentationUrls.Convert]}
360370 *
@@ -372,6 +382,10 @@ public class Convert<T, out C>(
372382 */
373383public fun <T > Convert <T , * >.to (type : KType ): DataFrame <T > = asColumn { it.convertTo(type) }
374384
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+
375389/* * [Convert per row col][Convert.perRowCol] to provide a new value for every selected cell giving its column. */
376390@ExcludeFromSources
377391private interface SeeAlsoConvertPerRowCol
@@ -512,8 +526,7 @@ public inline fun <T, C, reified R> Convert<T, C>.perRowCol(
512526 *
513527 * The target type is provided as a reified type argument.
514528 *
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].
517530 *
518531 * @param [C] The target type to convert values to.
519532 * @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
523536/* *
524537 * Converts values in this column to the specified [type].
525538 *
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].
528540 *
529541 * @param type The target type, provided as a [KType], to convert values to.
530542 * @return A new [DataColumn] with the values converted to [type].
0 commit comments