
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
숙제중 오류 발생하였는데, 어디가 잘못된건지 못찾겠습니다..
작성한 코드 및 에러 메세지
오류 발생 시, 작성한 코드 전체와 에러 메시지를 첨부해 주세요.
Tip 2) Ctrl+A(맥의 경우 Command+A) 단축키로 코드를 한 번에 선택할 수 있어요!
import pandas as pd
all_date = pd.read_table('done_detail.csv', sep=',')
all_date.head()
format='%Y-%m-%dT%H:%M:%S.%f'
all_date['done_date_time'] = pd.to_datetime(all_date['done_date'], format=format) #이줄이 에러라고 뜹니다
all_date.tail(5)
-
ValueError Traceback (most recent call last)
<ipython-input-20-29e8e032a9e8> in <cell line: 6>()
4
5 format='%Y-%m-%dT%H:%M:%S.%f'
----> 6 all_date['done_date_time'] = pd.to_datetime(all_date['done_date'], format=format)
7 all_date.tail(5)
4 frames
/usr/local/lib/python3.10/dist-packages/pandas/_libs/tslibs/strptime.pyx in pandas._libs.tslibs.strptime.array_strptime()
ValueError: time data "2020-08-07 12:02:16" doesn't match format "%Y-%m-%dT%H:%M:%S.%f", at position 0. You might want to try:
- passing `format` if your strings have a consistent format;
- passing `format='ISO8601'` if your strings are all ISO8601 but not necessarily in exactly the same format;
- passing `format='mixed'`, and the format will be inferred for each element individually. You might want to use `dayfirst` alongside this.
