I am struggling with the following scenario:
I am making a shiny app and some of the functionalities are written in python.
In my shiny app, I have a dateInput with dateP9 identifier and I am using that dateInput as an input in my python code.
This is the chunk of my app:
library(reticulate)
date_PnL = eventReactive(input$goP9,{
x = paste("'",gsub("-","",input$dateP9),"'",sep="")
source_python("historical_PnL_for_A_Date.py")
result = get_Historical_PnL(x)
result
})
renderTable({date_PnL})
and the python function is :
def get_Historical_PnL(day):
n_days = 62
level = 0.5
method = 'hist'
data = read_position(day)
PnL = get_pnl_hist2(data,day)
PnL = PnL.iloc[0:62,]
return PnL
I get the following stack of errors:
Warning: Error in if: argument is of length zero
149: py_to_r.datetime.datetime
147: py_maybe_convert
146: [[.python.builtin.dic
144: source_python
143: eventReactiveHandler [<text>#4]
99: date_PnL
98: renderTable [<text>#9]
97: func
84: origRenderFunc
83: output$out6066c03f277c834d
3: <Anonymous>
1: markdown::run
Any help would be very much appreciated
question from:
https://stackoverflow.com/questions/65913357/python-datetime-conversion-in-reticulate-gives-error 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…