Initializing DataFrames

153 views
Skip to first unread message

0kto

unread,
Jul 8, 2016, 7:45:54 AM7/8/16
to julia-stats
Hi all,

I am using DataFrames to import couple of hundreds of DataFiles, that get merged into one single DataFrame. Currently I am wondering about what would be the best way to initialize that DataFrame, and hope you can help me.

If I do something like

df_all
= DataFrame()

for file in filelist
  df_tmp
=  readtable(file)
 
... do stuff to the df_tmp...
  append
!(df_all,df_tmp)
end

I obviously can't match the column numbers, and everything fails. I wold need to initialize the DataFrame using sth like

df_all
= DataFrame(:col1 = Float64[], :col2 = Int64[])

but I have 26 columns, and from experiment to experiment they tend to change. Useful is setting up a Dictionary, that relates Columns to Eltypes, but there is currently no way of supplying that to the initialization process.

Is there something I missed? Or could easier initialization routines be implemented?

Thank you, Max

0kto

unread,
Aug 2, 2016, 9:48:22 AM8/2/16
to julia-stats
Solution:

df = DataFrame(column_eltypes::Vector, cnames::Vector, nrows::Integer)

Found in the source code.
Reply all
Reply to author
Forward
0 new messages