SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def random_dates(start, end, n=10):
  2.     start_u = start.value//10**9
  3.     end_u = end.value//10**9
  4.     return pd.to_datetime(np.random.randint(start_u, end_u, n), unit='s')
  5.  
  6. np.random.seed(0)
  7. df = pd.DataFrame(np.random.random(3255000).reshape(465000,7))  # same shape as my data
  8. df['date'] = random_dates(pd.to_datetime('1990-01-01'), pd.to_datetime('2018-01-01'), 465000)
  9. df = df.set_index([0, 'date'])
  10. df = df.sort_values(by=[3])  # unsort indices, just in case
  11. df.index.lexsort_depth
  12. > 0
  13. df.index.is_monotonic()
  14. > False
  15. df.loc[(0.9987185534991936, pd.to_datetime('2012-04-16 07:04:34'))]
  16. # no warning
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top