Blog
Five Python Tips You Won’t Find in Most Curriculums

Our Python for Data Analysis course at Xebia Data Academy has been well established for at least five years (with tweaks here and there to continually improve). It’s packed with the Python essentials: data types, loops, functions, and core pandas concepts: .assign()
,.loc[]
, and .groupby()
.
But what you won’t read on the course overview:
I always include a few extra tips and tricks. They’re not officially part of the course, but they still attract some of the best questions, plus the biggest “aha!” moments.
Whether it’s because someone asks “is there a BETWEEN in Python?” or I just can’t help myself (because f-strings are awesome), here are five bonus topics I tend to sneak into every course.
1. Methods vs Functions: The Python identity crisis everyone has at some point
In every class I teach, I am always prepared for some groans or confused faces, and they always come up when it’s time to talk about Python syntax. At some point, a question like this will come up:
“Why do I use type(list)
instead of list.append()
?”
The confusion around syntax is commonly due to the differences between functions vs methods.
- Functions are stand-alone and take a variety of different data types as input -
type()
will take any data type where len can be used on any array-like data type (lists, strings, tuples, etc.) - Methods are functions attached to objects. So
list.append()
is a method that updates a list by adding a single item. It doesn’t make sense to apply the append method to something like an integer, so it is bound to the list data type only.
This 5-minute detour pays off big - understanding this early helps you read documentation, debug code, and grasp syntax much faster.
2. Pandas Methods You Didn't Know You Needed: .isin()
and .between()
The SQL users who join our courses breathe a sigh of relief when I show them these familiar friends:
df.loc[df['category'].isin(['A', 'B', 'C'])]
➝ Just likeWHERE category IN ('A', 'B', 'C')
df[df['score'].between(50, 80)]
➝ Just likeWHERE score BETWEEN 50 AND 80
These remove the need to combine filters with the and (`&`) / or (`|`) operators, AND builds a useful bridge from SQL to Python. Even better, the `between` method has the optional inclusive
parameter for more control – something not offered in native SQL.
3. .size vs .count(): Subtle and important differences
When grouping data in pandas, students often reach for .count()
without realizing what it’s actually doing, or what other options are out there. In the course, I welcome the opportunity to show them this subtle difference at work.
Let’s say we have a dataframe df
:
The following code produces two different values when applying count
vs size
:
Did you spot the NaN values in the name column? This opens the door to discussing missing values (NaNs in pandas) and how .count()
ignores them, while .size
doesn’t. And for the SQL crowd in the back:
COUNT(column)
in SQL =.count()
in pandasCOUNT(*)
in SQL =.size()
in pandas
It's a small difference,but it solves big questions such as Why are my counts off? Why is a group missing? Where did those missing values go?
4. f-Strings: Because readability is gold
Once learners are comfortable with variables and strings, I just can’t not show them f-strings:
With an f-string
name = "Lucy"
height = 171
print(f"Hello, my name is {name} and I am {height / 100:.2f}m!")
without an f-string 🙁
name = "Lucy"
height = 171
print("Hello, my name is " + name + " and I am " + str(height / 100) + "m!")
They’re simple, clean, and so much easier than juggling strings, concatenation and type-casting. Not only are they cool, you’re bound to see them again, since they can be a useful tool in generating labels, file paths, or dynamic queries, which are super common in data workflows.
5. Lambda Functions + GroupBy: Custom aggregation magic
I don’t like using the term magic in training, because it can make things feel inaccessible. But honestly, when I use custom aggregations in a groupby I feel like I’m playing with magic.
Let’s say you want to find the range of the num_items
from the df
we saw earlier. There is no range
method built-in to pandas, so what’s your option? Probably something like this:
Ok great, now how to do that in a groupby? Well, you can combine a groupby with a lambda function:
I use this so much in my daily code that it feels wrong to gatekeep it. Now you can also play with this little magic trick!
Five Python Tricks by Xebia Academy
These five extras aren't officially required – call them unofficial extras, teaching hacks, or Python party tricks if you will – but they always spark the best questions, insightful "aha" moments and those are the moments that stick.
----
Would you like to upgrade your Python skills?
Join me for the course “Python for Data Analysis” on August 11–12 in Amsterdam — I’ll be leading the sessions and would love to see you there!
P.S. While you’re at it, check out all the courses offered during Data Summer School. Whether you’re into Python, Machine Learning, LLMs, or GenAI, there’s something for you — all with an extra special 30% Summer Special discount!

Lucy Sheppard
Principal Data Educator
Contact