Here is some code which reads a DataFrame from a (csv) file:
using DataFrames
using CSV
df = DataFrame(CSV.File(filename))
By default, I think the columns are String type. (Maybe it is inferred from the data values?)
… either way -
Is there a way to specify the data types of each column when reading the data from file?
For this to work, obviously the column names need to be known in advance. In this case, that’s ok, because the DataFrame stores some data which has some constraints on its schema. There are a fixed set of column names, and the data type for each one is known in advance of reading the file from disk.
If this isn’t possible - and I suspect it may not be - is there a way to convert the columns using something equivalent to this python code:
No way to do it using the DataFrames library? I guess it makes sense that the type conversion is done at the time of reading the file though… Thanks for the tips… guess I was looking in the wrong place…