https://kotlinlang.org logo
#datascience
Title
# datascience
d

Dinesh Sharma

03/13/2024, 2:41 PM
Need help with DataFrame. I am reading a csv file using DataFrame.readCSV(file) but it’s messing up large number and converting them into scientific notation… how can I avoid this?
j

Jolan Rensen [JB]

03/18/2024, 1:47 PM
Do you have an example of some of these numbers? 🙂 I'm curious to see what happens with them
Oh and please also provide your
Locale.getDefault()
value, as that can influence how numbers are parsed
d

Dinesh Sharma

03/18/2024, 2:30 PM
number 16096801 -> 1.61E+07
11742066 -> 1.17E+07
default locale is UK
j

Jolan Rensen [JB]

03/18/2024, 4:08 PM
Looks like it's parsed as a
Double
instead of an `Int`/`Long`. The number is not converted or stored differently, but Kotlin renders
Double.toString()
like that when they become too large. I tried to reproduce it with those numbers on my machine, but for me they are correctly recognized, so I'm not sure why they aren't on yours. However, there's actually a way to force the types of
readCSV()
by supplying
colTypes = map("YOUR_COL_NAME" to ColType.Long)
.
d

Dinesh Sharma

03/18/2024, 4:40 PM
ah brilliant! Thanks
I will try that