일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- Sheety
- 오류
- 웹크롤링
- twilio
- 프로젝트
- phython
- Game
- 계산기
- Pygame
- udemy
- Endpoint
- 프로그램
- HTTP
- 웹페이지
- ndarray
- 파싱
- 쉬티
- 최저가
- 부트스트랩
- 유데미
- API
- 상태코드
- class
- API플랫폼
- SMTP
- HTML
- 파이썬
- Tequila
- Python
- 게임
Archives
- Today
- Total
데이터 분석가
ValueError: could not convert string to float: '2013-01-01' 본문
파이썬 (python) 에러코드 모음
ValueError: could not convert string to float: '2013-01-01'
PlintAn 2023. 8. 22. 22:11ValueError: could not convert string to float: '2013-01-01'
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
해결방법
날짜를 pandas의 datetime 타입으로 변환:
df['date'] = df['date'].apply(lambda x: pd.to_datetime(x))
연, 월, 일을 각각의 별도 컬럼으로 분리:
df['year'] = df['date'].apply(lambda x: pd.to_datetime(x).year)
df['month'] = df['date'].apply(lambda x: pd.to_datetime(x).month)
df['day'] = df['date'].apply(lambda x: pd.to_datetime(x).day)
날짜를 Unix timestamp로 변환:
df['timestamp'] = df['date'].apply(lambda x: int(pd.to_datetime(x).timestamp()))
'파이썬 (python) 에러코드 모음' 카테고리의 다른 글
ValueError: Multi-dimensional indexing (0) | 2023.08.24 |
---|---|
ValueError: Multi-dimensional indexing (0) | 2023.08.20 |
폰트 깨지는 문제 해결 (0) | 2023.08.20 |
TypeError: 'int' object is not iterable (0) | 2023.02.14 |
Comments