#convert pyobject datetime to arraydatafram

1 messages · Page 1 of 1 (latest)

bold mountain
#

help me please, I try to convert pyobject from pycall to dataframe or timeseres type (currently df), it work if I do not include the datetime column, how do I call the datetime column/index of pycall pyobject.

using PyCall, DataFrames, Dates
function stream(ticker, interval, period)
    #using PyCall, CSV, DataFrames, Dates
    #pd = pyimport("pandas")
    yf = pyimport("yfinance")
    data = yf.download(ticker, interval = interval, period = period)
    dt = data[:Datetime]
    values = data[:values]
    return DataFrame(datetime=dt,
                    open=values[:,1],
                    high=values[:,2],
                    low=values[:,3],
                    close=values[:,4],
                    volume=values[:,6])
end 
stream("GOTO.JK", "1m", "1d")```
bold mountain
#

I found the solution myself, but really appreciate if you have a better way using PyCall, DataFrames, Dates function stream(ticker, interval, period) np = pyimport("numpy") yf = pyimport("yfinance") data = yf.download(ticker, interval = interval, period = period) values = data[:values] dt = data[:index].astype(np.int64) dt = Nanosecond.(dt) + DateTime(1970) return DataFrame(datetime=dt, open=values[:,1], high=values[:,2], low=values[:,3], close=values[:,4], volume=values[:,6]) end