dataframe icon indicating copy to clipboard operation
dataframe copied to clipboard

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

Open devcrocod opened this issue 1 year ago • 4 comments

Reproduce

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

Expected

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

result:

   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

   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

devcrocod avatar Jan 22 '24 13:01 devcrocod