-
Notifications
You must be signed in to change notification settings - Fork 48
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
Overload toDataFrame for basic types to avoid surprising results #314
Conversation
core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/toDataFrame.kt
Outdated
Show resolved
Hide resolved
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.
I agree we need to take care of primitives. A list of strings gives me a dataframe of string lengths without the new overloads haha.
However, do all of these need to be overloads for toDataFrame
? Or can these just be moved to createDataFrameImpl
?
I don't think so. At east we'll lose the ability to return this typed dataframe |
Of course! You're right :) |
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 rest looks good!
Btw, maybe we should also add overloads for (primitive) arrays toDataFrame, since they aren't iterables
}.cast() | ||
|
||
@DataSchema | ||
public interface ValueProperty<T> { |
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 maybe be moved to a separate file, similar to KeyValueProperty :)
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.
I'd prefer it here, doesn't have much value on its own i think
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.
thought the same about KeyValueProperty, but who knows, we cannot know everything a user might want :) And a value-only DataSchema seems to me exactly the sort of thing people might want to use (or create themselves)
Not sure, so let's return to it later c: I'll merge this |
Without overloads Iterable.toDataFrame produces unexpected result
=>
length
0 3
1 2
2 null
I think it will be more reasonable to create a dataframe with a single column for all basic types (numbers, strings, char, boolean), and do reflection scan for everything else