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)

Was this helpful?

0 / 0

Cookie Consent with Real Cookie Banner