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
