Skip to content
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

Display list of data classes as table #294

Closed
mwisnicki opened this issue Jul 3, 2021 · 5 comments
Closed

Display list of data classes as table #294

mwisnicki opened this issue Jul 3, 2021 · 5 comments

Comments

@mwisnicki
Copy link

A list of data classes should be rendered as a table like the DataFrame rather than simple toString()

@mwisnicki
Copy link
Author

mwisnicki commented Jul 3, 2021

This gets me close to what I want (although columns are ordered lexicographically rather than as defined in data class constructor) but IMHO should be default behavior:

%use krangl
someListOfDataClasses.asDataFrame()

@altavir
Copy link
Contributor

altavir commented Jul 3, 2021

This one will require a compiler plugin since it is not possible to decompose a generic data class (or any other class) without it. It could be done with a serialization plugin and would work for and any class marked as @Serializable.

@ileasile
Copy link
Contributor

ileasile commented Jul 3, 2021

@mwisnicki You can achive the same thing using dataframe library. But I don't think it should be a default behaviour

@ileasile
Copy link
Contributor

ileasile commented Jul 3, 2021

@altavir in case of data classes (which we can check in RT with KClass<*>.isData) all the constructor arguments are properties, and we can get all constructor arguments in the proper order: KClass<*>.primaryConstructor?.parameters. Some properties that are not present in primary constructor have a chance to stay unordered but it is generally acceptable

@ileasile
Copy link
Contributor

ileasile commented Jul 3, 2021

I will close this issue. I've created the issue in dataframe about this problem: Kotlin/dataframe#32

@ileasile ileasile closed this as completed Jul 3, 2021
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

No branches or pull requests

3 participants