inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

173만명의 커뮤니티!! 함께 토론해봐요.

to_timedelta 에러에 관련해서 질문드립니다.

미해결

파이썬 데이터시각화 분석 실전 프로젝트

안녕하세요 강의 잘 듣고 있습니다. 마라톤 데이터 가공 2 강의를 듣던 중 Step 5단계에서 오류가 발생합니다. 사용하고 있는 파이썬 버전은 3.8.12이고 pandas 버전은 1.3.4입니다. 강의 내용대로 순차적으로 실습 진행 중 Step 5단계에서 오류가 발생하여 Step 5단계의 다른 내용을 모두 주석 후에 marathon_2015_2017['5K'] = pd.to_timedelta(marathon_2015_2017['5K']) 이 코드만 실행해 보았는데요 그럼에도 오류가 발생합니다. 혹시나 해서 csv파일을 열어 보았는데 시간데이터 중 '-' 로 표시된 부분이 종종 있었습니다. 제 생각에는 '-'라는 문자가 있으니 null도 아니고 시간데이터도 아니다 보니 문제가 발생하는 것 같은 예감입니다. 아래에 오류 내용을 그대로 첨부하겠습니다. 도움 주시면 감사하겠습니다. --------------------------------------------------------------------------- ValueError Traceback (most recent call last) /opt/homebrew/Caskroom/miniforge/base/envs/DV/lib/python3.8/site-packages/pandas/_libs/tslibs/timedeltas.pyx in pandas._libs.tslibs.timedeltas.array_to_timedelta64 () /opt/homebrew/Caskroom/miniforge/base/envs/DV/lib/python3.8/site-packages/pandas/_libs/tslibs/timedeltas.pyx in pandas._libs.tslibs.timedeltas.parse_timedelta_string () ValueError : symbols w/o a number During handling of the above exception, another exception occurred: ValueError Traceback (most recent call last) /var/folders/zl/7hy5k6z55zz2b286tv4bbk740000gn/T/ipykernel_48790/1493613945.py in <module> 6 7 # Convert using pandas to_timedelta method ----> 8 marathon_2015_2017 [ '5K' ] = pd . to_timedelta ( marathon_2015_2017 [ '5K' ] ) 9 # marathon_2015_2017['10K'] = pd.to_timedelta(marathon_2015_2017['10K']) 10 # marathon_2015_2017['15K'] = pd.to_timedelta(marathon_2015_2017['15K']) /opt/homebrew/Caskroom/miniforge/base/envs/DV/lib/python3.8/site-packages/pandas/core/tools/timedeltas.py in to_timedelta (arg, unit, errors) 122 return arg 123 elif isinstance ( arg , ABCSeries ) : --> 124 values = _convert_listlike ( arg . _values , unit = unit , errors = errors ) 125 return arg . _constructor ( values , index = arg . index , name = arg . name ) 126 elif isinstance ( arg , ABCIndex ) : /opt/homebrew/Caskroom/miniforge/base/envs/DV/lib/python3.8/site-packages/pandas/core/tools/timedeltas.py in _convert_listlike (arg, unit, errors, name) 171 172 try : --> 173 td64arr = sequence_to_td64ns ( arg , unit = unit , errors = errors , copy = False ) [ 0 ] 174 except ValueError : 175 if errors == "ignore" : /opt/homebrew/Caskroom/miniforge/base/envs/DV/lib/python3.8/site-packages/pandas/core/arrays/timedeltas.py in sequence_to_td64ns (data, copy, unit, errors) 989 if is_object_dtype ( data . dtype ) or is_string_dtype ( data . dtype ) : 990 # no need to make a copy, need to convert if string-dtyped --> 991 data = objects_to_td64ns ( data , unit = unit , errors = errors ) 992 copy = False 993 /opt/homebrew/Caskroom/miniforge/base/envs/DV/lib/python3.8/site-packages/pandas/core/arrays/timedeltas.py in objects_to_td64ns (data, unit, errors) 1098 values = np . array ( data , dtype = np . object_ , copy = False ) 1099 -> 1100 result = array_to_timedelta64 ( values , unit = unit , errors = errors ) 1101 return result . view ( "timedelta64[ns]" ) 1102 /opt/homebrew/Caskroom/miniforge/base/envs/DV/lib/python3.8/site-packages/pandas/_libs/tslibs/timedeltas.pyx in pandas._libs.tslibs.timedeltas.array_to_timedelta64 () /opt/homebrew/Caskroom/miniforge/base/envs/DV/lib/python3.8/site-packages/pandas/_libs/tslibs/timedeltas.pyx in pandas._libs.tslibs.timedeltas.array_to_timedelta64 () /opt/homebrew/Caskroom/miniforge/base/envs/DV/lib/python3.8/site-packages/pandas/_libs/tslibs/timedeltas.pyx in pandas._libs.tslibs.timedeltas.convert_to_timedelta64 () /opt/homebrew/Caskroom/miniforge/base/envs/DV/lib/python3.8/site-packages/pandas/_libs/tslibs/timedeltas.pyx in pandas._libs.tslibs.timedeltas.parse_timedelta_string () ValueError : symbols w/o a number

  • to_timedelta
  • python
  • pandas
Hyeon Kyeong Cho 댓글 2 좋아요 0 조회수 581

인기 태그

인프런 TOP Writers

주간 인기글