Created
March 20, 2021 14:38
-
-
Save databyjp/261075391e37eb16209786b33b1f616f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def normalise_price(df): | |
df = df.assign(norm_close=0) | |
for symbol in df["symbol"].unique(): | |
symbol_df = df[df["symbol"] == symbol] | |
min_date = symbol_df["date"].min() | |
ref_val = symbol_df[symbol_df["date"] == min_date]["close"].values[0] | |
df.loc[df["symbol"] == symbol, "norm_close"] = df.loc[df["symbol"] == symbol, "close"] / ref_val | |
return df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment