커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
3주차 과제
undefined주차
북마크
황*이
댓글
3
추천
0
조회수
8
조회수
8
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


똑같이 파일을 열고 코드를 넣었는데 왜 저는 에러가 나는 걸까요?




스파르타 즉문즉답




작성한 코드 및 에러 메세지

import pandas as pd
sparta_data = pd.read_table('/content/done_detail.csv',sep=',')


format='%Y-%m-%dT%H:%M:%S.%f'
sparta_data['done_date_time'] = pd.to_datetime(sparta_data['done_date'], format=format)


ValueError                                Traceback (most recent call last)
<ipython-input-12-5286c5ded3cd> in <cell line: 5>()
      3 
      4 format='%Y-%m-%dT%H:%M:%S.%f'
----> 5 sparta_data['done_date_time'] = pd.to_datetime(sparta_data['done_date'], format=format)
      6 
      7 
/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.


취소
 공유
취소
댓글 0
댓글 알림
나의얼굴