<p>Pandas code can get quite nasty inside of your jupyter notebook. It's not just the syntax, it's the infinite amount of scrolling too. In this series of videos we're going to explore a way to clean this up. This series of videos is inspired by the <a href="https://tomaugspurger.github.io/modern-1-intro.html">modern pandas blogposts</a> originally written by Tom Augspurger.</p>
The code shown below does it's job, but it is bound to get out of hand.
import pandas as pd df = pd.read_csv('https://calmcode.io/datasets/bigmac.csv') df2 = (df .assign(date=lambda d: pd.to_datetime(d['date'])) .sort_values(['currency_code', 'date']) .groupby('currency_code') .agg(n=('date', 'count'))) df.loc[lambda d: d['currency_code'].isin(df2[df2['n'] >= 32].index)]
df2 especially is a code smell.