[Python Error] Excel does not support datetimes with timezones. Please ensure that datetimes are timezone unaware before writing to Excel.

2021. 12. 1. 23:56·Error code 모음/4. Python errors
반응형

 

 

1. 에러 발생 원인


크롤링 후 날짜 데이터를 엑셀의 형태로 저장하려했으나 

엑셀에서 지원하는 형식이 아니어서 위 에러가 발생함

 

 

 

 

2. 해결 방법


df['date'] = old_dates
df['date'] = df['date'].apply(lambda a: pd.to_datetime(a).date()) 
# .date() removes timezone

스텍오버 플로우에 있는 방법을 사용하여 apply 에 lambda 함수를 사용하여

date 컬럼의 타입을 변경함

 

 

 

 

3. 참고링크


https://stackoverflow.com/questions/61802080/excelwriter-valueerror-excel-does-not-support-datetime-with-timezone-when-savin

 

ExcelWriter ValueError: Excel does not support datetime with timezone when saving df to Excel

I'm running on this issue for quite a while now. I set the writer as follows: writer = pd.ExcelWriter(arquivo+'.xlsx', engine = 'xlsxwriter', options = {'remove_timezone': True}) df.to_excel(writ...

stackoverflow.com

 

반응형
저작자표시 비영리 변경금지 (새창열림)

'Error code 모음 > 4. Python errors' 카테고리의 다른 글

[ Python Error ] dtypewarning columns have mixed types.specify dtype option on import or set low_memory=false  (0) 2022.06.28
[ Python Error ] ImportError: cannot import name 'enums' from 'google.cloud.speech'  (0) 2021.12.12
[ Python Error ] 'datetime' has no 'fromtimestamp'  (2) 2021.11.04
[Python Error] 'tqdm_notebook' object has no attribute 'disp'  (0) 2021.11.03
[Python] PIP Install: Cannot combine --user and --target 에러  (0) 2021.07.08
'Error code 모음/4. Python errors' 카테고리의 다른 글
  • [ Python Error ] dtypewarning columns have mixed types.specify dtype option on import or set low_memory=false
  • [ Python Error ] ImportError: cannot import name 'enums' from 'google.cloud.speech'
  • [ Python Error ] 'datetime' has no 'fromtimestamp'
  • [Python Error] 'tqdm_notebook' object has no attribute 'disp'
쟈누
쟈누
Ad astra per aspera
    반응형
  • 쟈누
    쟈누의 기록공간
    쟈누
  • 전체
    오늘
    어제
    • 분류 전체보기 (444)
      • AWS (31)
        • Glue (4)
        • S3 (1)
      • 클라우드 (0)
      • Data Engineering (37)
        • GitHub (10)
        • NiFi (11)
        • Spark (10)
        • Snowflake (0)
        • 머신러닝, AI (6)
      • 언어 (118)
        • 데이터 베이스 (42)
        • JAVA (9)
        • Python (34)
        • Java Script (15)
        • Linux (18)
      • 프로젝트, 인강 그리고 책 (30)
        • Spotify Project (7)
        • RASA chatbot Project (9)
        • Naver shopping Project (6)
        • 빅데이터를 지탱하는 기술 (8)
      • OLD (56)
        • IT 용어 사전 (13)
        • Front End (12)
        • Back End (31)
      • Error code 모음 (165)
        • 1. SQL errors (17)
        • 2. Hadoop errors (20)
        • 3. Linux Errors (14)
        • 4. Python errors (33)
        • 5. JAVA, Spring errors (41)
        • 6. Jav Script errors (10)
        • 7. Dev Tools errors (9)
        • 8. Git errors (8)
        • 9. Jenkins Errors (4)
        • 10. airflow Errors (2)
        • 11. Aws errors (7)
      • 개인 (1)
        • 책 (1)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
    • 블로그 관리
    • 글쓰기
  • 링크

  • 공지사항

    • 간단한 블로그 소개
  • 인기 글

  • 태그

    SQL
    python error
    install
    AWS
    error
    자바
    java
    node
    Python
    파이썬
    NiFi
    API
    설치
    json
    Spring
    Git
    linux
    리눅스
    에러
    MySQL
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
쟈누
[Python Error] Excel does not support datetimes with timezones. Please ensure that datetimes are timezone unaware before writing to Excel.
상단으로

티스토리툴바