Skip to content

median is broken for "mixed" number types #566

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

Closed
cmelchior opened this issue Jan 20, 2024 · 2 comments · Fixed by #1122
Closed

median is broken for "mixed" number types #566

cmelchior opened this issue Jan 20, 2024 · 2 comments · Fixed by #1122
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
@Jolanrensen
Copy link
Collaborator

Could be fixed in #961

@Jolanrensen Jolanrensen linked a pull request Apr 23, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants