3 min read
Excel is a spreadsheet program. You click cells, type formulas and see results immediately. It is excellent for small files and quick calculations, and many people already know it.
Its weaknesses: steps are manual and hard to repeat exactly, mistakes hide inside cells, and one sheet is limited to about one million rows. A Pandas script, by contrast, records every step and can run again on next month's file in seconds.
Below, the Excel steps 'filter sales above 100' and 'sum the visible cells' are done with Pandas.
import pandas as pd
df = pd.DataFrame({"product": ["A", "B", "C", "D"], "sales": [50, 150, 200, 90]})
big = df[df["sales"] > 100] # Excel: filter sales > 100
print(big)
print("Total:", big["sales"].sum()) # Excel: SUM of filtered cells
Code explained:
| Code | What it does |
|---|---|
| df["sales"] > 100 | True/False for every row (like a filter rule) |
| df[ ... ] | Keeps only the True rows |
| .sum() | Same as the Excel SUM function |
Output explained:
| Output | Meaning |
|---|---|
| Rows B and C | Only sales above 100 remain |
| Total: 350 | 150 + 200 |
Watch out: Pandas will not auto-update when you edit a cell like Excel. You rerun the code.
Quick check: Which tool reruns the same steps on new data with one command?
Answer: Pandas (a script).
💬 Comments & Discussion
No comments yet
Be the first to share your thoughts!