前提・実現したいこと
時刻データの入っているcsvファイルを読み込み、datetime形に変換する際に以下のエラーができるのでtry exceptで捕捉しようとしたがエラーがそのまま表示される。
発生している問題・エラーメッセージ
Traceback (most recent call last):
File "C:\Users\user\source\repos\IFperiod\IFperiod\IFperiod.py", line 69, in <module>
a=str((excel.iat[c,0]))
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\pandas\core\indexing.py", line 2200, in getitem
return self.obj._get_value(*key, takeable=self._takeable)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\pandas\core\frame.py", line 2826, in _get_value
return com.maybe_box_datetimelike(series._values[index])
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\pandas\core\common.py", line 89, in maybe_box_datetimelike
value = tslibs.Timestamp(value)
File "pandas_libs\tslibs\timestamps.pyx", line 412, in pandas._libs.tslibs.timestamps.Timestamp.new
File "pandas_libs\tslibs\conversion.pyx", line 320, in pandas._libs.tslibs.conversion.convert_to_tsobject
File "pandas_libs\tslibs\conversion.pyx", line 399, in pandas._libs.tslibs.conversion.convert_datetime_to_tsobject
File "pandas_libs\tslibs\np_datetime.pyx", line 118, in pandas._libs.tslibs.np_datetime.check_dts_bounds
pandas._libs.tslibs.np_datetime.OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 3880-01-05 00:00:51
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\user\source\repos\IFperiod\IFperiod\IFperiod.py", line 72, in <module>
TIME_excel.append((datetime.datetime.strptime((str(excel.iat[c,0])),"%Y-%m-%d %H:%M:%S")))
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\pandas\core\indexing.py", line 2200, in getitem
return self.obj._get_value(*key, takeable=self._takeable)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\pandas\core\frame.py", line 2826, in _get_value
return com.maybe_box_datetimelike(series._values[index])
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\pandas\core\common.py", line 89, in maybe_box_datetimelike
value = tslibs.Timestamp(value)
File "pandas_libs\tslibs\timestamps.pyx", line 412, in pandas._libs.tslibs.timestamps.Timestamp.new
File "pandas_libs\tslibs\conversion.pyx", line 320, in pandas._libs.tslibs.conversion.convert_to_tsobject
File "pandas_libs\tslibs\conversion.pyx", line 399, in pandas._libs.tslibs.conversion.convert_datetime_to_tsobject
File "pandas_libs\tslibs\np_datetime.pyx", line 118, in pandas._libs.tslibs.np_datetime.check_dts_bounds
pandas._libs.tslibs.np_datetime.OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 3880-01-05 00:00:51
続行するには何かキーを押してください . . .
該当のソースコード
python 3.7
try: a=str((excel.iat[c,0])) except : print("error")
試したこと
try except:でこのエラーを捕捉を試みたが捕捉できない。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
あなたの回答
tips
プレビュー