Python Snippets

How to shift time in timedate index in pandas dataframe:

df.set_index(df.index + pd.Timedelta(hours=5))

How to sample n times from an object (e.g.) an array without replacement?

import numpy as np
np.random.choice(['a','g','k'],3, replace=False)


Discover more from Master the Math

Subscribe to get the latest posts sent to your email.

Leave a Reply

Scroll to Top
Cookie Consent with Real Cookie Banner