pandas로 빠르고 간편한 데이터 적재
Amany Mahfouz
Instructor
pandas에서 스프레드시트 로딩 함수: read_excel()import pandas as pd # Excel 파일 읽기 survey_data = pd.read_excel("fcc_survey.xlsx")# 처음 5행 보기 print(survey_data.head())
Age AttendedBootcamp ... SchoolMajor StudentDebtOwe
0 28.0 0.0 ... NaN 20000
1 22.0 0.0 ... NaN NaN
2 19.0 0.0 ... NaN NaN
3 26.0 0.0 ... Cinematography And Film 7000
4 20.0 0.0 ... NaN NaN
[5 rows x 98 columns]
read_excel()은 read_csv()와 공통 키워드 인자가 많습니다nrows: 로드할 행 수 제한skiprows: 건너뛸 행 수 또는 행 번호 지정usecols: 이름, 위치 번호, 또는 문자(예: "A:P")로 열 선택
# 메타데이터 헤더를 건너뛰고 파일의 W-AB, AR 열 읽기 survey_data = pd.read_excel("fcc_survey_with_headers.xlsx", skiprows=2, usecols="W:AB, AR")# 데이터 확인 print(survey_data.head())
CommuteTime CountryCitizen ... EmploymentFieldOther EmploymentStatus Income
0 35.0 United States of America ... NaN Employed for wages 32000.0
1 90.0 United States of America ... NaN Employed for wages 15000.0
2 45.0 United States of America ... NaN Employed for wages 48000.0
3 45.0 United States of America ... NaN Employed for wages 43000.0
4 10.0 United States of America ... NaN Employed for wages 6000.0
[5 rows x 7 columns]
pandas로 빠르고 간편한 데이터 적재