Networkite中的python日期时间转换出现错误

2024-05-18 06:33:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在与以下情景作斗争:

我正在制作一个闪亮的应用程序,其中一些功能是用python编写的。 在我闪亮的应用程序中,我有一个带有dateP9标识符的dateInput,我正在python代码中使用该dateInput作为输入

这是我的应用程序的一块:

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})

python函数是:

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

我得到了以下一堆错误:

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

任何帮助都将不胜感激


Tags: py应用程序sourceinputdatagetdatetimedate