覆盖pandas datetime转换,其中coerce = True不会

时间:2015-07-30 06:29:41

标签: python datetime pandas coerce

我的数据中必须有一个错误的日期,但我宁愿继续将此设置为缺失。但是,我试图强迫这种做法失败了,我认为没有其他选择。有什么可做的?

相关的一行是:

all_treatments['date'] = pd.to_datetime(all_treatments['INDATUMA'], format='%Y%m%d', coerce=True)

错误是:

Traceback (most recent call last):
 File "treatments3_noiopro.py", line 76, in <module>
   all_treatments['date'] = pd.to_datetime(all_treatments['INDATUMA'], format='%Y%m%d', coerce=True)
 File "/home/seidav/anaconda/lib/python2.7/site-packages/pandas/tseries/tools.py", line 340, in to_datetime
   values = _convert_listlike(arg.values, False, format)
 File "/home/seidav/anaconda/lib/python2.7/site-packages/pandas/tseries/tools.py", line 333, in _convert_listlike
   raise e
ValueError: day is out of range for month

我在Linux下使用版本pandas 0.16.2 np19py26_0,iopro 1.7.1 np19py27_p0和python 2.7.10 0。

0 个答案:

没有答案