pythonbeginner
Read Multi-Sheet Excel Files
Load, merge, and process data from multiple Excel sheets using pandas ExcelFile context manager.
pythonPress ⌘/Ctrl + Shift + C to copy
import pandas as pd
with pd.ExcelFile('report.xlsx', engine='openpyxl') as xls:
print('Sheets:', xls.sheet_names)
dfs = {sheet: pd.read_excel(xls, sheet_name=sheet) for sheet in xls.sheet_names}
all_data = pd.concat(dfs.values(), keys=dfs.keys(), names=['sheet'])
all_data = all_data.reset_index(level='sheet')
print(all_data.groupby('sheet').size())Use Cases
- Excel ETL
- multi-sheet reports
- data consolidation
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
pythonintermediate
Read Large CSV in Chunks with Pandas
Process CSV files larger than RAM by reading in chunks — memory-efficient ETL pattern for data pipelines.
Best for: Processing multi-GB CSV files without running out of memory
#pandas#csv
pythonintermediate
Pandas Vectorised Operations vs Apply
Compare apply vs vectorised pandas operations for performance-critical column transformations.
Best for: feature engineering
#pandas#vectorization
pythonbeginner
SQLite + Pandas Local Data Pipeline
Run a lightweight local ETL with SQLite and pandas: load CSV, transform, persist to SQLite.
Best for: local analytics
#sqlite#pandas
pythonbeginner
Flatten Nested JSON with pandas
Use pd.json_normalize to flatten deeply nested API responses into a flat DataFrame.
Best for: API response flattening
#pandas#json