스프레드시트 소개

pandas로 빠르고 간편한 데이터 적재

Amany Mahfouz

Instructor

스프레드시트

  • Excel 파일이라고도 함
  • 데이터는 행과 열의 셀로 이루어진 표 형태로 저장됩니다
  • 플랫 파일과 달리 서식과 수식을 포함할 수 있습니다
  • 하나의 통합 문서에 여러 시트가 있을 수 있습니다
pandas로 빠르고 간편한 데이터 적재

스프레드시트 불러오기

  • pandas에서 스프레드시트 로딩 함수: read_excel()

스프레드시트 프로그램의 FreeCodeCamp New Developer Survey 데이터 스크린샷

pandas로 빠르고 간편한 데이터 적재

스프레드시트 불러오기

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]
pandas로 빠르고 간편한 데이터 적재

선택 열/행 불러오기

메타데이터 헤더 행이 있는 설문 스프레드시트

여러 개의 작은 데이터 표가 있는 인보이스 스프레드시트

pandas로 빠르고 간편한 데이터 적재

선택 열/행 불러오기

  • read_excel()은 read_csv()와 공통 키워드 인자가 많습니다
    • nrows: 로드할 행 수 제한
    • skiprows: 건너뛸 행 수 또는 행 번호 지정
    • usecols: 이름, 위치 번호, 또는 문자(예: "A:P")로 열 선택
pandas로 빠르고 간편한 데이터 적재

선택 열/행 불러오기

pandas로 빠르고 간편한 데이터 적재

선택 열/행 불러오기

# 메타데이터 헤더를 건너뛰고 파일의 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로 빠르고 간편한 데이터 적재

Ayo berlatih!

pandas로 빠르고 간편한 데이터 적재

Preparing Video For Download...