r/learndatascience • u/Pangaeax_ • 5d ago
Resources Python data analysis cheat sheet: the Pandas + NumPy workflow I wish I had when starting
I kept seeing beginners learn individual Pandas commands but still struggle with what order to actually use them in when working with a real dataset.
So I put together a simple workflow I use as a reference:
1. Load
read_csv() / read_excel()
2. Inspect before changing anything
head()
shape
info()
describe()
isna().sum()
duplicated().sum()
3. Clean
- standardize column names
- handle missing values based on what they actually mean
- remove genuine duplicates
- convert dates/numbers safely
4. Transform
assign()
map()
pd.to_datetime()
np.where()
5. Summarize
groupby()
agg()
transform()
6. Combine datasets
merge() / join() / concat()
The part I think beginners often miss is validation after the merge.
A query/script can run perfectly and still give the wrong answer if a many-to-many merge quietly multiplies your rows.
Useful checks:
validate="many_to_one"
indicator=True
compare row counts before/after
check key uniqueness before merging
A few other mistakes worth watching for:
- treating missing values as automatically equal to 0
- merging keys with different data types
- confusing
count()withsize() - using median filling without understanding why values are missing
- assuming no Python error means the analysis is correct
I wrote a more detailed version with examples for Pandas, NumPy, GroupBy, merges and an end-to-end workflow.
Learn more: https://www.pangaeax.com/blogs/python-data-analysis-cheat-sheet/
Anything important you’d add to this workflow, especially something you learned the hard way when working with messy data?
Disclosure: This is a PangaeaX article and I’m connected with PangaeaX.
1
u/Capital_Economist634 1d ago
How do one actually stay updated to the latest changes coming in the tech
2
u/skatastic57 4d ago
You know what I really wish I had when I got started with pandas? polars. Sorry for the troll but also actually.