-
Notifications
You must be signed in to change notification settings - Fork 71
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
base: master
Are you sure you want to change the base?
Convert KDocs #1134
Conversation
@@ -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]. |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The meaning is
- You can convert values to some type (
to<Double>()
)
or - You can convert values using your converter (
with { SomeParserToSomeType.parse(it, options) }
)
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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>()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYM?
There was a problem hiding this comment.
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]` }` |
There was a problem hiding this comment.
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]. | |||
* |
There was a problem hiding this comment.
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], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*an IFRAME
There was a problem hiding this comment.
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], |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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]} | ||
* |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYM?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
Closes #1019.