将cvs内容添加到新文件中时,将NaN浮动为整数

时间:2018-12-18 15:47:59

标签: python-2.7

故事: 该脚本之前已用于将两个特定的csv文件合并为一个。 这些csv具有相同的标头,并用于提供回归。

现在有两个带有新标题的新csv文件可用,现在出现此错误。

我需要开始更改吗?我查看了所请求的csv,并且始终带有“开始时间”,其值(例如12323090等)。

这些值在该函数中不再起作用了吗?

调试器运行结果

Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 
2017.3.4\helpers\pydev\pydevd.py", line 1668, in <module>
main()
File "C:\Program Files\JetBrains\PyCharm Community Edition 
2017.3.4\helpers\pydev\pydevd.py", line 1662, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files\JetBrains\PyCharm Community Edition 
2017.3.4\helpers\pydev\pydevd.py", line 1072, in run
pydev_imports.execfile(file, globals, locals)  # execute the script

文件 “ D:/Sandbox/TD_Excel_ExpanderScript/EBA_ENDU_REG_SCR/end_regr_test_original.py”,

line 251, in <module>
ref_ev['Start Time Rel']=ref_ev['Start Time'].apply(lambda x: str(datetime.timedelta(seconds=x/1e6)))
File "C:\Python27_64\lib\site-packages\pandas\core\series.py", line 2294, in 
apply mapped = lib.map_infer(values, f, convert=convert_dtype)
File "pandas\src\inference.pyx", line 1207, in pandas.lib.map_infer 
(pandas\lib.c:66124)

文件 “ D:/Sandbox/TD_Excel_ExpanderScript/EBA_ENDU_REG_SCR/end_regr_test_original.py”,

line 251, in <lambda>
ref_ev['Start Time Rel']=ref_ev['Start Time'].apply(lambda x: str(datetime.timedelta(seconds=x/1e6)))
ValueError: cannot convert float NaN to integer

0 个答案:

没有答案