Skip to content

Instantly share code, notes, and snippets.

@Cimbali

Cimbali/setup.py Secret

Last active June 10, 2021 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cimbali/79bbb64d3e18d08eb2c2ade30b2a0b0f to your computer and use it in GitHub Desktop.
Save Cimbali/79bbb64d3e18d08eb2c2ade30b2a0b0f to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import numpy as np
import pandas as pd
df = pd.DataFrame(np.random.randint(1900, 2000, 50), columns=['year'])
df['age_bin'] = pd.cut(pd.Timestamp.today().year - df['year'],
bins=[-np.inf,30,40,50,60,70,np.inf],
labels=['-30','30-39','40-49','50-59','60-69','70+'])
df['location'] = pd.Series(np.random.randint(1, 6, 50)).map({
1: 'england',
2: 'ireland',
3: 'scotland',
4: 'wales',
5: 'jersey',
6: 'gurnsey',
}).fillna('Other')
df['status'] = pd.Series(np.random.randint(1, 6, 50)).map({
1: 'married',
2: 'divorced',
3: 'single',
4: 'window',
}).fillna('Other')
print(df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment