| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- 상태코드
- Pygame
- 게임
- 부트스트랩
- 웹페이지
- class
- 프로젝트
- SMTP
- 프로그램
- 웹크롤링
- ndarray
- API플랫폼
- HTTP
- phython
- Endpoint
- 파이썬
- Python
- 계산기
- Tequila
- 쉬티
- HTML
- 최저가
- 파싱
- 유데미
- 오류
- twilio
- API
- Sheety
- udemy
- Game
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