
Daily bite-sized #Python & #DataScience gems. Maker of cool tees for devs. #MachineLearning #DataAnalytics #Programming #Coding #WebDeveloper
Joined July 2023
- Tweets105
- Following22
- Followers0
- Likes124
glob finds files matching a pattern.
Perfect for:
- Batch processing
- Data pipelines
- File management
One tip a day. Follow for more.
#Python #DataScience 🐍
zip stops at the shortest list. zip_longest keeps going with fillvalue.
Perfect for:
- Data alignment
- Padding incomplete data
- CSV parsing with missing fields
One tip a day. Follow for more.
#Python #DataScience 🐍
pdb is a built-in Python debugger.
Add this ONE line anywhere:
import pdb; pdb.set_trace()
Execution pauses and you can:
- Inspect variables (p variable)
- Step through code (n, s)
- Continue or quit (c, q)
One tip a day. Follow for more.
#Python #DataScience 🐍
Stop using range(len()) to loop through lists.
❌ Ugly:
for i in range(len(list)):
print(i, list[i])
✅ Clean:
for i, item in enumerate(list):
print(i, item)
enumerate() gives you index AND value in one line.
One tip a day. Follow for more.
#Python #LearnToCode 🐍
1
2
Counter is a dictionary for counting things.
Manual way:
counts = {}
for item in items:
counts[item] = counts.get(item, 0) + 1
Counter way:
from collections import Counter
counts = Counter(items)
One tip a day. Follow for more.
#Python #DataScience 🐍
4
Flatten nested lists with chain.from_iterable().
Nested = [[1,2], [3,4], [5,6]]
chain.from_iterable (nested)
→ [1,2,3,4,5,6]
Why better than manual loops:
- Faster (C implementation)
- Cleaner
- Memory efficient
One tip a day. Follow for more.
#Python #DataScience 🐍
3
partial creates a new function with some arguments pre-filled.
With partial:
square = partial(power, exponent=2)
Perfect for:
- Specializing general functions
- Callbacks with fixed parameters
- Reducing repetition
One tip a day. Follow for more.
#Python #DataScience 🐍
2
💡 My "pro" moments:
1. Using enumerate() instead of range(len())
2. List comprehensions
3. defaultdict for grouping
4. Writing my first decorator (felt like magic)
What was YOUR moment? Be honest.
#Python #LearnToCode 🐍
2
f-strings can format numbers, dates, and alignment.
Numbers:
{value:.2f} # 2 decimals
{value:,} # commas
{value:.1%} # percentage
Dates:
{now:%Y-%m-%d} # 2026-06-14
Alignment:
{name:<10} # left align
One tip a day. Follow for more.
#Python #DataScience 🐍

















