Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pierrelouisbescond/cb8b66b0ac2d733a17d1d08dec9b3afc to your computer and use it in GitHub Desktop.
Save pierrelouisbescond/cb8b66b0ac2d733a17d1d08dec9b3afc to your computer and use it in GitHub Desktop.
for feature in ["x1","x2","x3"]:
# We create a shifted feature matching the original one
feature_new_name = feature + "_shifted"
# The shift is determined randomly
random_shift = np.random.randint(10,50)
df[feature_new_name] = df[feature].shift(-random_shift)
print(feature, "shifted of", -random_shift)
df = df.dropna()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment