Hi all,
I must be doing something wrong. I can’t get vcat and plot to work inside a script. When I use them in the terminal the commands work fine but inside a script vcat returns no error and an empty dataframe. Plot has a similar behavior. No response inside a script but in the terminal works fine.
Please read the guidelines here and post a MWE. Thank you.
2 Likes
b_d = string(Date(begin_date, “mm/dd/yyyy”))
e_d = string(Date(end_date, "mm/dd/yyyy"))
global s_d_df = DataFrame(underlying_symbol = [], quote_datetime = [], open = [], high = [], low = [], close = [], trade_volume = [], vwap = [], bid = [], ask = [])
global tmp_stock_df = DataFrame()
# Get the file list from the data directory
global file_list = glob("*3600*.csv", path)
# Filter to select csv files
# File names include the date, sort from earliest date to latest
sort!(file_list)
# Extract the file names associated with the date timeline from the file list
start_row_num = findfirst(x -> occursin(b_d, x), file_list)
len = length(file_list)
last_file = file_list[len]
end_file_date = Date(last_file[31:40])
if Date(e_d) > end_file_date
e_d = Dates.format(end_file_date, "yyyy-mm-dd")
end
end_row_num = findfirst(x -> occursin(e_d, x), file_list)
f_l = file_list[start_row_num:end_row_num]
# Build a dataframe containing the data
len = length(f_l)
tmp_stock_df = DataFrame(CSV.File(f_l[1]))
vcat(s_d_df, tmp_stock_df)
println(s_d_df)
for i = 2:len
tmp_stock_df = DataFrame(CSV.File(f_l[i]))
tmp_stock_df.quote_datetime = map((x) -> DateTime(x, "yyyy-mm-dd HH:MM:SS"), tmp_stock_df.quote_datetime)
DataFrames.vcat(s_d_df, tmp_stock_df)
end
Your code does not run.
There is no plot command.
Include all packages being used.
This is suspicious and probably not what you actually want. vcat
creates a new array (or data frame) with the concatenated result and returns it. Since you’re not using that returned value, it has no effect at all.
You need something like:
result = vcat(s_d_df, tmp_stock_df)
where result
will now hold the concatenated output.
Ok. That worked. Thank you. More on plot later.