knime中报错:Traceback (most recent call last): File "E:\ProgramData\Anaconda3\liKeyError: 'timestamp'

在使用Knime的时候,因为要把python2的代码换成python3 的代码,不知为啥就突然爆出这些错误,第一次可以执行,但是第二次就爆粗了。
 

Traceback (most recent call last):
  File "E:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 3078, in get_loc
    return self._engine.get_loc(key)
  File "pandas\_libs\index.pyx", line 140, in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\index.pyx", line 162, in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\hashtable_class_helper.pxi", line 1492, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas\_libs\hashtable_class_helper.pxi", line 1500, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'timestamp'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\KNIME\knime-full_3.6.0\plugins\org.knime.python2_3.6.0.v201807061638\py\PythonKernelBase.py", line 278, in execute
    exec(source_code, self._exec_env, self._exec_env)
  File "<string>", line 7, in <module>
  File "E:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py", line 3909, in set_index
    level = frame[col]._values
  File "E:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py", line 2688, in __getitem__
    return self._getitem_column(key)
  File "E:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py", line 2695, in _getitem_column
    return self._get_item_cache(key)
  File "E:\ProgramData\Anaconda3\lib\site-packages\pandas\core\generic.py", line 2489, in _get_item_cache
    values = self._data.get(item)
  File "E:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals.py", line 4115, in get
    loc = self.items.get_loc(item)
  File "E:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexes\base.py", line 3080, in get_loc
    return self._engine.get_loc(self._maybe_cast_indexer(key))
  File "pandas\_libs\index.pyx", line 140, in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\index.pyx", line 162, in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\hashtable_class_helper.pxi", line 1492, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas\_libs\hashtable_class_helper.pxi", line 1500, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'timestamp'

如下开始分析:

由报错的关键字来看,出问题的就是timestamp这个字段信息,所以我们从源头来看,在这个节点中,它的类型是Local Date Time类型的 字面意思来看应该是本地日期类型。

然后一直往下走,直接到出错之前的那个节点来看它的类型是什么

在这里,我们看到这里是Date and Time类型,已经改变了,通过各种排查,发现python的内部其实是不认识这种类型的,还必须转换成另外一种类型 ,在Node Repository中查找time,有个to legacy的类型,这个类型是可以被python所接受的,所以在出错之前需要进行转换成这个类型的数据,这样一来就可以正常运行了。 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值