Skip to content

Convert KDocs #1134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Convert KDocs #1134

wants to merge 4 commits into from

Conversation

AndrewKis
Copy link
Contributor

Closes #1019.

@Jolanrensen Jolanrensen self-requested a review April 22, 2025 11:01
@@ -48,12 +56,171 @@ import kotlin.reflect.KType
import kotlin.reflect.full.isSubtypeOf
import kotlin.reflect.typeOf

/**
* Converts the values in the specified [columns\] to a target type
* or using a custom converter, keeping their original names and positions within the [DataFrame].
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence doesn't work "Converts the values in the specified [columns] to a target type or using a custom converter". Maybe rewrite it to "a supported target type or a custom one".

Copy link
Contributor Author

@AndrewKis AndrewKis Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The meaning is

  1. You can convert values to some type (to<Double>())
    or
  2. You can convert values using your converter (with { SomeParserToSomeType.parse(it, options) })

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Converts the values in the specified [columns] either to a supported target type or using a custom converter"

wdyt?

* Converts the values in the specified [columns\] to a target type
* or using a custom converter, keeping their original names and positions within the [DataFrame].
*
* This function does not immediately convert the columns but instead select columns to convert and
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

selects*

* returns a [Convert],
* which serves as an intermediate step.
* The [Convert] object allows you to specify how the selected
* columns will be converted using methods such as
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you say "such as" I expect a handful of examples, not all of them.

* [toURL][Convert.toURL],
* [toIFrame][Convert.toIFrame],
* [toImg][Convert.toImg], and [toDataFrames][Convert.toDataFrames]
* that return a new [DataFrame] with updated columns.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be nice is a small list of available conversions, like how it is on the website. People can then decide to check the grammar for all the specific overloads or simply use to<Type>()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYM?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like here https://kotlin.github.io/dataframe/convert.html, just a list of supported types

* {@include [DslGrammarLink]}
* {@include [LineBreak]}
*
* **[`convert`][convert]**` { columnsSelector: `[`ColumnsSelector`][ColumnsSelector]` }`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the cases where you write "backtick, space, something..., space, backtick". It's a rule in markdown that single spaces like this are trimmed away: https://github.github.com/gfm/#code-spans. It doesn't happen in the current markdown renderer in intellij, but I think this is just a matter of time. It can be solved by writing 2 spaces instead of one, like ` { columnsSelector: `. It's not required for cases like ` }`, because it doesn't have a space at the beginning ánd end.

@@ -147,9 +499,27 @@ public fun AnyCol.convertTo(newType: KType): AnyCol =
else -> convertToTypeImpl(newType, null)
}

/**
* Converts values in this `String` column to the specified type [C].
*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm maybe we should link to parse? since this is just like parse but with a predefined return type for the values

public fun <T : Any> DataColumn<T?>.convertToBoolean(): DataColumn<Boolean?> = convertTo()

// region convert URL

/**
* Converts values in the [URL] columns previously selected with [convert] to the [IFRAME],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*an IFRAME

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the others as well, like "the IMG" -> an IMG

@JvmName("convertToURLFromStringNullable")
public fun DataColumn<String?>.convertToURL(): DataColumn<URL?> = map { it?.let { URL(it) } }

/**
* Converts values in the [String] columns previously selected with [convert] to the [URL],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no "the" before "URL", either "to a URL" or "to URL"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the others as well :)

* where the first element is used as the column name, and the remaining elements as values.
*
* For more information: {@include [DocumentationUrls.Convert]}
*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could use a visual example likely... But I'm not entirely sure how

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYM?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like:

containsColumns = false
[[a, b, c], [1, 2, 3], [4, 5, 6]] ->

containsColumns = true
[[a, 1, 4], [b, 2, 5], [c, 3, 6]] ->

a b c
1 2 3
4 5 6

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes it a bit easier to understand maybe

*
* By default, treats the first inner list as a header (column names), and the remaining lists as rows.
* If [containsColumns] is `true`, interprets each inner list as a column,
* where the first element is used as the column name, and the remaining elements as values.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could also do with a visual, but I'm not sure how

@AndrewKis AndrewKis requested a review from Jolanrensen April 22, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add KDocs for convert
2 participants