-
Couldn't load subscription status.
- Fork 76
Update createDataFrame.md with compiler-plugin friendly examples #1519
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?
Conversation
d836c6e to
0a65d11
Compare
0a65d11 to
8861f89
Compare
8861f89 to
b51f36a
Compare
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.
Nice! It really shows off the power of toDataFrame() :)
| // SampleStart | ||
| val categories = listOf("Electronics", "Books", "Clothing") | ||
| // DataFrame with 4 columns and 7 rows | ||
| (0 until 7).toDataFrame { |
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.
maybe nice to show off ..< instead of until :) but up to you
| "reviews" from { | ||
| val reviewCount = Random.nextInt(0, 8) | ||
| (0 until reviewCount).toDataFrame { | ||
| val ratings: DataColumn<Int> = expr { Random.nextInt(1, 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.
could you use the Kotlin Random extension functions which take ranges instead? :) With those it's immediately clear which number is included and which is not Random.nextInt(1..5), whereas with Random.nextInt(1, 6) I'd have to know 6 is excluded
Replaced some examples that don't work with compiler plugin and use outdated API that we plan to replace, with
toDataFrameoperation.Now examples with random data can be copy-pasted into project with compiler plugin. Plus, generally it's much more powerful approach that can produce sophisticated dataframes:
In the process i found that our rendering doesn't work for some of the examples and fixed it.
