Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 오블완
- pandas
- git
- java
- github
- PostgreSQL
- 리눅스
- rsync
- oracle
- MariaDB
- docker
- group by
- mysql
- 티스토리챌린지
- Javascript
- 추상클래스
- mssql
- spring
- 트랜잭션
- Linux
- analytics4
- DBMS
- JPA
- Python
- SQL
- MongoDB
- 자바
- 호이스팅
- 명령어
- IntelliJ
Archives
- Today
- Total
hanker
ValueError: time data "" doesn't match format "%Y-%m-%d", at position 1. You might want to try: 본문
Python/Python Error
ValueError: time data "" doesn't match format "%Y-%m-%d", at position 1. You might want to try:
hanker 2025. 2. 27. 01:20반응형
ValueError: time data "" doesn't match format "%Y-%m-%d", at position 1. You might want to try:
해당 오류는 pandas.to_datetime을 사용할 때 날짜 문자열이 예상 형식과 일치하지 않을 때 발생한다.
해결방법
1. 정확한 날짜 형식 지정하기
df['date'] = pd.to_datetime(df['date'], format="%Y/%m/%d")
format에 정확한 날짜 형식을 지정해준다.
2. 다양한 형식의 날짜가 섞여 있는 경우
df['date'] = pd.to_datetime(df['date'], format='mixed')
다양한 형식의 날짜가 섞여 있을 경우, format='mixed'를 사용하여 각 날짜의 형식을 개별적으로 추론한다.
위 코드를 통해 날짜 문자열의 형식 불일치 문제를 해결할 수 있다.
반응형