我需要比较到的日期,一个是来自数据帧的日期,另一个只是我使用deltatime到两天前的日期。像这样:elif np.greater(ddate,datetime.now() - timedelta(2)):
问题是,这段代码一直工作得很好,直到今天,当我尝试比较这些日期时,我得到了以下错误:
TypeError: '>' not supported between instances of 'int' and 'datetime.datetime'
我正在使用此代码从excel中提取日期:
ddate = df_earning_calander.loc[df_earning_calander.index == stock_symbol, 'date'][stock_symbol]
为了找到问题,我打印了ddate
结果,我找到了这个。
(此代码位于循环中,因此第一行是正确的,而第二行不是)
2019-08-08 00:00:00
KHC 2019-08-08
当其中一个值还包含其旁边的列时,错误将跳转。。。这很奇怪,因为数据帧是这样构建的:print(ddate,bmo_amc,stock_symbol,company_name)
2019-08-08 00:00:00 Before The Open KOP Koppers Holdings
我认为这可能是问题所在,尽管我不确定
这就是Excel的构建方式:
你知道怎么解决这个问题吗
目前没有回答
相关问题 更多 >
编程相关推荐