Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def random_dates(start, end, n=10):
- start_u = start.value//10**9
- end_u = end.value//10**9
- return pd.to_datetime(np.random.randint(start_u, end_u, n), unit='s')
- np.random.seed(0)
- df = pd.DataFrame(np.random.random(3255000).reshape(465000,7)) # same shape as my data
- df['date'] = random_dates(pd.to_datetime('1990-01-01'), pd.to_datetime('2018-01-01'), 465000)
- df = df.set_index([0, 'date'])
- df = df.sort_values(by=[3]) # unsort indices, just in case
- df.index.lexsort_depth
- > 0
- df.index.is_monotonic()
- > False
- df.loc[(0.9987185534991936, pd.to_datetime('2012-04-16 07:04:34'))]
- # no warning
Add Comment
Please, Sign In to add comment