liveBook · Manning

Read_excel

As explained in Pandas Workout: 200 exercises to make you a stronger data analyst

read_excel is a pandas function that reads spreadsheet files into a DataFrame.

read_excel is a pandas function for creating a DataFrame from an Excel spreadsheet. Use it when the input is an Excel file rather than a CSV; it creates a new object instead of modifying an existing DataFrame. section 5.10 section 5.9

Load the Titanic spreadsheet

Set the spreadsheet path and load it into a DataFrame: filename = '../data/titanic3.xls'; df = pd.read_excel(filename). Continue by inspecting missing values with df.isnull().sum(), then decide whether to drop or fill affected data. section 5.10 section 5.9

Configure the resulting DataFrame through parameters that shape its columns and index:

  • Use index_col to select one or more index columns. section 5.10
  • Use usecols to restrict which spreadsheet columns become DataFrame columns. section 5.10
  • Use names to specify column names. section 5.10
filename = '../data/titanic3.xls'
df = pd.read_excel(filename)

Inspect the concise loading example for an Excel file. section 5.10

How Pandas Workout: 200 exercises to make you a stronger data analyst covers it

How deep it goes
Explains invocation and column-shaping parameters, but does not descend into spreadsheet parsing internals.
Examples
Uses the titanic3.xls passenger dataset and follows loading with null-value inspection.
What it assumes
Assumes familiarity with pandas DataFrames and contrasts Excel loading with read_csv.
What you can do after
Apply it via pandas to load an Excel spreadsheet into a DataFrame for subsequent analysis and cleaning.
How it connects
Connects Excel loading with DataFrame objects, read_csv, indexes, and missing-data analysis.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pandas Workout: 200 exercises to make you a stronger data analyst. The section links point to the parts of the book it draws on.