Open devcrocod opened 10 months ago
Thanks @devcrocod
I'm sorry, I cannot reproduce it directly. It returns the same result for me.
It might be a locale thing (as I see your Doubles have "," instead "."). Convert relies on parse
to parse Strings. It defaults to your system locale and interprets "," as the decimal splitter and "." as the thousands splitter.
This may be different from the default String.toDouble()
function from the stdlib you call the other time.
I feel like this is intended behavior, though a bit unfortunate in this example.
Since you're trying to parse a String I'd recommend using parse
as you can define extra ParserOptions
, such as a Locale
.
Yes, this is a problem specifically with the locale. But I expect to get one result:
df.filter { !stars.startsWith("Un") }.convert { stars }.with { it.toDouble() }
,
df.filter { !stars.startsWith("Un") }.convert { stars }.toDouble()
Because in my opinion, toDouble()
is just a shortcut for with
.
Yes, this is a problem specifically with the locale. But I expect to get one result:
df.filter { !stars.startsWith("Un") }.convert { stars }.with { it.toDouble() }
,df.filter { !stars.startsWith("Un") }.convert { stars }.toDouble()
Because in my opinion,
toDouble()
is just a shortcut forwith
.
I know, it should, but I'd argue our solution is "better" as it takes locale into account. It's the stlib toDouble()
function that should change, but that's not something we can do.
Reproduce
stars
column to a double typeExpected
result:
Actual
Version and Environment
Name: kotlin-jupyter-kernel, Version: 0.11.0.385
dataframe version: 0.12.1