











































Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Esta página não é visível na pré-visualização
Não perca as partes importantes!












































S T R E A M L I N E D D ATA I N G E S T I O N W I T H PA N D A S Amany Mahfouz Instructor
Also known as Excel les Data stored in tabular form, with cells arranged in rows and columns Unlike at les, can have forma ing and formulas Multiple spreadsheets can exist in a workbook
import pandas as pd
survey_data = pd.read_excel("fcc_survey.xlsx")
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]
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. 1 90.0 United States of America ... NaN Employed for wages 15000. 2 45.0 United States of America ... NaN Employed for wages 48000. 3 45.0 United States of America ... NaN Employed for wages 43000. 4 10.0 United States of America ... NaN Employed for wages 6000. [5 rows x 7 columns]
S T R E A M L I N E D D ATA I N G E S T I O N W I T H PA N D A S Amany Mahfouz Instructor
read_excel() loads the rst sheet in an Excel le by default Use the sheet_name keyword argument to load other sheets Specify spreadsheets by name and/or (zero-indexed) position number Pass a list of names/numbers to load more than one sheet at a time Any arguments passed to read_excel() apply to all sheets read
survey_data_sheet2 = pd.read_excel('fcc_survey.xlsx', sheet_name= 1 )
survey_data_2017 = pd.read_excel('fcc_survey.xlsx', sheet_name='2017') print(survey_data_sheet2.equals(survey_data_2017)) True
Passing sheet_name=None to read_excel() reads all sheets in a workbook survey_responses = pd.read_excel("fcc_survey.xlsx", sheet_name=None) print(type(survey_responses))
for key, value in survey_responses.items(): print(key, type(value)) 2016 2017
S T R E A M L I N E D D ATA I N G E S T I O N W I T H PA N D A S Amany Mahfouz Instructor