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

median is broken for "mixed" number types #566

Open
cmelchior opened this issue Jan 20, 2024 · 1 comment
Open

median is broken for "mixed" number types #566

cmelchior opened this issue Jan 20, 2024 · 1 comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Milestone

Comments

@cmelchior
Copy link
Contributor

If you have a DataFrame consisting of a mix of Number types, calling median on it will break.

Example:

val df = dataFrameOf("a")(
    1, 
    2L,
    2.0f,
    3.0,
)
df.median("a")

Will throw:

java.lang.ClassCastException: class java.lang.Long cannot be cast to class java.lang.Integer (java.lang.Long and java.lang.Integer are in module java.base of loader 'bootstrap') at java.base/java.lang.Integer.compareTo(Integer.java:59) at org.jetbrains.kotlinx.dataframe.math.MedianKt.quickSelect(median.kt:43)

@Jolanrensen Jolanrensen added bug Something isn't working duplicate This issue or pull request already exists labels Jan 22, 2024
@Jolanrensen
Copy link
Collaborator

Yup, as mentioned here #558 only Comparable is supported, Number is not supported (yet) but can still be called. This should be fixed indeed. I would say Number should be attempted to be converted toDouble() if it's not a known type.

@zaleslaw zaleslaw added this to the 0.14.0 milestone Apr 23, 2024
@zaleslaw zaleslaw modified the milestones: 0.14.0, Backlog Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants