드레:
코딩 뿌시기
드레:
전체 방문자
오늘
어제
  • 분류 전체보기 (268)
    • Python (74)
      • Python 기초 (42)
      • Numpy (8)
      • Pandas (22)
    • Machine Learning (31)
      • Machine Learning (1)
      • Deep Learning (27)
    • AWS (22)
      • RDS (3)
      • EC2 (9)
      • Lambda (8)
      • S3 (2)
    • MySQL (24)
    • Git (8)
    • Streamlit (12)
    • REST API (22)
    • Java (24)
    • Android (36)
    • Debugging (15)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • 딥러닝
  • JWT
  • Transfer Learning
  • API
  • CNN
  • 서버리스
  • flask
  • rest api
  • pandas
  • volley
  • 네이버 API
  • AWS Lambda
  • Python
  • Lambda
  • aws s3
  • Retrofit2
  • Callback
  • EC2
  • 액션바
  • Ann
  • github
  • GET
  • 안드로이드 스튜디오
  • 깃이그노어
  • tensorflow
  • Java
  • Streamlit
  • AWS
  • fine tuning
  • serverless

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
드레:

코딩 뿌시기

판다스 read_csv 에러 - ParserError: Error tokenizing data.
Debugging

판다스 read_csv 에러 - ParserError: Error tokenizing data.

2023. 1. 8. 20:58

pd.read_csv() 를 하는 과정에서 에러가 발생했다.

ParserError: Error tokenizing data. C error: Expected 23 fields in line 533719, saw 24

이 에러는 다른 라인들보다 구분자(seperator)의 갯수가 많은 라인이 있을 때 발생한다.

 

직접 csv 파일을 수정해도 되지만,

위처럼 데이터가 많은 경우는 찾아서 수정하는 것도 일이기 때문에

read_csv의 파라미터로 에러가 발생한 라인만 제거하고 가져올 수 있다.

 

파라미터에 error_bad_lines= False 를 추가해준다.

chicago_df_1 = pd.read_csv('Chicago_Crimes_2005_to_2007.csv', 
                           error_bad_lines=False, 
                           index_col=0)

 

 

참고로 pd.read_csv() 할 때 다른 라인들보다 구분자의 갯수가 적은 라인이 있는 경우는,

에러 없이 부족한 데이터가 NaN으로 채워진다.

'Debugging' 카테고리의 다른 글

포스트맨 에러 - Error: write EPROTO 64064520:error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBER:../../../../src/third_party/boringssl/src/ssl/tls_record.cc:242:  (0) 2023.01.17
MySQL - 예약어를 테이블명으로 썼을 때 에러 해결방법  (0) 2023.01.17
REST API - GET할 때 TypeError  (0) 2023.01.04
git pull 에러 - error: Your local changes to the following files would be overwritten by merge  (0) 2022.12.23
streamlit_kmeans 진행중 에러 - UnicodeDecodeError  (0) 2022.12.23
    'Debugging' 카테고리의 다른 글
    • 포스트맨 에러 - Error: write EPROTO 64064520:error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBER:../../../../src/third_party/boringssl/src/ssl/tls_record.cc:242:
    • MySQL - 예약어를 테이블명으로 썼을 때 에러 해결방법
    • REST API - GET할 때 TypeError
    • git pull 에러 - error: Your local changes to the following files would be overwritten by merge
    드레:
    드레:

    티스토리툴바