张量流中的溢出错误

时间:2017-10-08 14:19:27

标签: python-3.x tensorflow jupyter-notebook

我写了这个函数来映射日期。

df1=pd.read_csv("database.csv")

def mapdateTotime(x):
    try:
        return time.mktime(datetime.datetime.strptime(x,
"%m/%d/%Y").timetuple())

    except ValueError:
        return time.mktime(datetime.datetime.strptime(x, "%Y-%m-%dT%H:%M:%S.%fZ").timetuple())

df1.Date = df1.Date.apply(mapdateTotime)

database.csv文件包含一些日期和时间值,我需要映射它们。 但我得到这个溢出错误。我该如何解决呢。

错误是:

    OverflowError                             Traceback (most recent call last)
<ipython-input-6-05c73c6f7120> in <module>()
      8     except ValueError:
      9         return time.mktime(datetime.datetime.strptime(x, "%Y-%m-%dT%H:%M:%S.%fZ").timetuple())
---> 10 df1.Date = df1.Date.apply(mapdateTotime)

c:\users\amol\appdata\local\programs\python\python36\lib\site-packages\pandas\core\series.py in apply(self, func, convert_dtype, args, **kwds)
   2353             else:
   2354                 values = self.asobject
-> 2355                 mapped = lib.map_infer(values, f, convert=convert_dtype)
   2356 
   2357         if len(mapped) and isinstance(mapped[0], Series):

pandas\_libs\src\inference.pyx in pandas._libs.lib.map_infer (pandas\_libs\lib.c:66645)()

<ipython-input-6-05c73c6f7120> in mapdateTotime(x)
      5 def mapdateTotime(x):
      6     try:
----> 7         return time.mktime(datetime.datetime.strptime(x, "%m/%d/%Y").timetuple())
      8     except ValueError:
      9         return time.mktime(datetime.datetime.strptime(x, "%Y-%m-%dT%H:%M:%S.%fZ").timetuple())

OverflowError: mktime argument out of range

0 个答案:

没有答案