Post

Pandas 파일입출력 - Excel과 CSV 파일 처리

Pandas 파일입출력 - Excel과 CSV 파일 처리

Pandas 파일입출력 - Excel과 CSV 파일 처리

파일입출력

Excel 불러오기

  • excel = pd.read_excel('경로',sheet_name='')
  • excel.head() : 불러온 excel 5행으로 확인
  • excel.keys() : excel sheet 조회
  • excel.to_excel('sample.xlsx', index=True) : excel 저장

CSV 불러오기

  • df = pd.read_csv('data/seoul_population.csv')
  • df.head(): 불러온 csv 5행으로 확인
  • df = pd.read_csv('data/seoul_population.csv', encoding='utf8') : encoding 문제가 있을시에 사용
  • df.to_csv('sample.csv', index=False) : CSV 저장
This post is licensed under CC BY 4.0 by the author.