Skip to content

Instantly share code, notes, and snippets.

@GeorgeSeif
Created October 10, 2019 23:25
Show Gist options
  • Save GeorgeSeif/ed574789e8e1d8229861826c08b60b24 to your computer and use it in GitHub Desktop.
Save GeorgeSeif/ed574789e8e1d8229861826c08b60b24 to your computer and use it in GitHub Desktop.
from itertools import product
import pandas as pd
import numpy as np
col_names = ["Day", "Month", "Year"]
df = pd.DataFrame(list(product([10, 11, 12], [8, 9], [2018, 2019])),
columns=col_names)
df['data'] = np.random.randn(len(df))
df = df.sort_values(['Year', 'Month'], ascending=[True, True])
print(df)
"""
Day Month Year data
0 10 8 2018 1.685356
4 11 8 2018 0.441383
8 12 8 2018 1.276089
2 10 9 2018 -0.260338
6 11 9 2018 0.404769
10 12 9 2018 -0.359598
1 10 8 2019 0.145498
5 11 8 2019 -0.731463
9 12 8 2019 -1.451633
3 10 9 2019 -0.988294
7 11 9 2019 -0.687049
11 12 9 2019 -0.067432
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment