Pandas tips and tricks
Shir Meir Lador
1.6K10

Thanks to Amir for posting the code for setting up Shir’s original example dataframe. Unfortunately though the code has some errors. Here is my correction:

import pandas as pd
df = pd.DataFrame([
["Chandler Bing","party","2017/08/04 08:00:00",51],
["Chandler Bing","party","2017/08/04 13:00:00",60],
["Chandler Bing","party","2017/08/04 15:00:00",59],
["Harry Kane","football","2017/08/04 13:00:00",80],
["Harry Kane","party","2017/08/04 11:00:00",90],
["Harry Kane","party","2017/08/04 07:00:00",68],
["John Doe","beach","2017/08/04 07:00:00",63],
["John Doe","beach","2017/08/04 12:00:00",61],
["John Doe","beach","2017/08/04 14:00:00",65],
["Joey Tribbiani","party","2017/08/04 09:00:00",54],
["Joey Tribbiani","party","2017/08/04 10:00:00",67],
["Joey Tribbiani","football","2017/08/04 08:00:00",84],
["Monica Geller","travel","2017/08/04 07:00:00",90],
["Monica Geller","travel","2017/08/04 08:00:00",96],
["Monica Geller","travel","2017/08/04 09:00:00",74],
["Phoebe Buffey","travel","2017/08/04 10:00:00",52],
["Phoebe Buffey","travel","2017/08/04 12:00:00",84],
["Phoebe Buffey","football","2017/08/04 15:00:00",58],
["Ross Geller","party","2017/08/04 09:00:00",96],
["Ross Geller","party","2017/08/04 11:00:00",81],
["Ross Geller","travel","2017/08/04 14:00:00",60]],
columns=["name","activity","timestamp","money_spent"])
df["timestamp"] = pd.to_datetime(df["timestamp"], yearfirst=True)
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.