Skip to content

Instantly share code, notes, and snippets.

@DalyaG
Created May 9, 2020 20:33
Show Gist options
  • Save DalyaG/daed0fc4044f0d677d500543213d2696 to your computer and use it in GitHub Desktop.
Save DalyaG/daed0fc4044f0d677d500543213d2696 to your computer and use it in GitHub Desktop.
Visualizing the Birthday Paradox
n_sample = 50
df_sample = df.sample(n=n_sample)
df_sample['birthday'] = (df_sample['date_of_birth']
.dt
.strftime('%m-%d'))
df_sample_grouped = (df_sample
.groupby(['birthday'])
.size()
.reset_index(name="n_pets"))
df_sample_grouped.plot.bar(x="birthday", y="n_pets", color='blue');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment