Kotlin / Kotlin/dataframe

Casting strings to double using `with { it.toDouble()}` and `toDouble()` gives different results

Open
#568 4 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Kotlin
Stars
1.1k
Forks
83
Avg merge
4d 12h
Merged PRs (30d)
30

Description

## Reproduce
1. Take the ramen dataset: https://www.kaggle.com/code/sujan97/complete-analysis-of-ramen-ratings/input
2.
```kotlin
val df = DataFrame.readCSV("ramen-ratings.csv").renameToCamelCase()
```
```kotlin
df.filter { !stars.startsWith("Un") }.convert { stars }.toDouble()
```
3. convert `stars` column to a double type
```kotlin
df.filter { !stars.startsWith("Un") }.convert { stars }.toDouble()
```

## Expected
```kotlin
df.filter { !stars.startsWith("Un") }.convert { stars }.with { it.toDouble() }
```

result:
```text
review# brand variety style country stars topTen
0 2580 New Touch T's Restaurant Tantanmen Cup Japan 3,75 null
1 2579 Just Way Noodles Spicy Hot Sesame Spicy Hot Se... Pack Taiwan 1,00 null
2 2578 Nissin Cup Noodles Chicken Vegetable Cup USA 2,25 null
3 2577 Wei Lih GGE Ramen Snack Tomato Flavor Pack Taiwan 2,75 null
4 2576 Ching's Secret Singapore Curry Pack India 3,75 null
```

## Actual

```text
review# brand variety style country stars topTen
0 2580 New Touch T's Restaurant Tantanmen Cup Japan 375,0 null
1 2579 Just Way Noodles Spicy Hot Sesame Spicy Hot Se... Pack Taiwan 1,0 null
2 2578 Nissin Cup Noodles Chicken Vegetable Cup USA 225,0 null
3 2577 Wei Lih GGE Ramen Snack Tomato Flavor Pack Taiwan 275,0 null
4 2576 Ching's Secret Singapore Curry Pack India 375,0 null
```

## Version and Environment

Name: kotlin-jupyter-kernel, Version: 0.11.0.385

dataframe version: 0.12.1

Contributor guide

Open the contributing guide

Research direction

Start with the reported `convert { stars }.toDouble()` and `convert { stars }.with { it.toDouble() }` calls, using the ramen CSV reproduction described in the issue. Compare how each conversion parses values such as `3,75` and `2,25`; done means both forms produce the same double values.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.