sliver__

[Pandas 데이터 분석] Chapter 2 - 데이터 입출력 본문

CS/Pandas

[Pandas 데이터 분석] Chapter 2 - 데이터 입출력

sliver__ 2022. 2. 21. 23:48
728x90

[외부 파일 읽어오기]

File Format Reader Writer
CSV read_csv to_csv
JSON read_json to_json
HTML read_html to_html
Local clipboard read_clipboard to_clipboard
HDF5 Format read_hdf to_hdf
SQL read_sql to_sql

[csv 파일]

pandas.read_csv( "파일 경로" )

# ?번째 행을 열지정
pandas.read_csv( "파일 경로" , header = ?)

# ?번째 열을 행 인덱스 지정
pandas.read_csv( "파일 경로" , index_col = ?)

 

[excel 파일]

pandas.read_excel("파일경로")

 

[json 파일]

pandas.read_json("파일경로")

 

[html 파일]

  • html 의 <table> 태그에서 표 형식의 데이터를 모두 찾아서 데이터 프레임으로 변환.
  • 여러 개의 데이터프레임을 원소로 갖는 리스트 반환
  • pandas.read_html("웹 주소(URL) 또는 HTML 파일 경로이름")

[데이터 저장하기]

[csv 파일로 저장]

DataFrame 객체.to_csv('파일 이름(경로)')

[json 파일로 저장]

DataFrame 객체.to_json('파일 경로(이름)')

[excel 파일로 저장]

DataFrame 객체.to_excel('파일 이름(경로)')

[여러개의 데이터 프레임을 하나의 excel 파일로 저장]

pandas.ExcelWriter("파일 이름(경로)")

출처 : 파이썬 머신러닝 판다스 데이터 분석

728x90
Comments