
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
안녕하세요 튜터님,
코드스니펫에서 복사한 코드를 사용했을 때, 날짜 포맷에 맞지 않는다는 오류가 발생하여 문의 드립니다.
확인 부탁드릴 수 있을까요?
감사합니다.
#라이브러리 불러오기
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
plt.rc('font', family='NanumBarunGothic')
sparta_data=pd.read_csv("/content/cohort_data.csv")
sparta_data.head()
format='%Y-%m-%dT%H:%M:%S.%f'
sparta_data['start_time'] = pd.to_datetime(sparta_data['created_at'], format=format,infer_datetime_format=True)
sparta_data.info()
<ipython-input-1-24d7a61ad2fb>:12: UserWarning: The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.
sparta_data['start_time'] = pd.to_datetime(sparta_data['created_at'], format=format,infer_datetime_format=True)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-1-24d7a61ad2fb> in <cell line: 12>()
10
11 format='%Y-%m-%dT%H:%M:%S.%f'
---> 12 sparta_data['start_time'] = pd.to_datetime(sparta_data['created_at'], format=format,infer_datetime_format=True)
13 sparta_data.info()
5 frames
/usr/local/lib/python3.10/dist-packages/pandas/_libs/tslibs/strptime.pyx in pandas._libs.tslibs.strptime.array_strptime()
ValueError: time data "2022. 8. 15" 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.
