Need help with DataFrame. I am reading a csv file ...
# datascience
d
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
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
number 16096801 -> 1.61E+07
11742066 -> 1.17E+07
default locale is UK
j
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
ah brilliant! Thanks
I will try that