Last active
October 6, 2022 15:04
-
-
Save h3ik0th/34d2921ea3981714e7bdcb80c88b71c1 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 myfunc0(b, c): | |
r = np.sqrt(np.mean((b - c)**2)) | |
return r | |
def variants(df, dftype): | |
dfX = df.copy() | |
print(dftype) | |
%timeit dfX["r1"] = (((dfX["B"] - dfX["C"])**2).mean())**0.5 | |
%timeit dfX["r2"] = np.sqrt( np.mean((dfX["B"] - dfX["C"])**2)) | |
%timeit dfX["r3"] = np.sqrt( np.mean((dfX["B"].values - dfX["C"].values)**2)) | |
%timeit dfX["r4"] = np.sqrt( np.mean((dfX["B"].to_numpy() - dfX["C"].to_numpy())**2)) | |
%timeit if dftype == "short:": dfX["r5"] = np.vectorize(myfunc0)(dfX["B"], dfX["C"]) | |
variants(dfS, "short:") | |
variants(dfM, "medium:") | |
variants(dfL, "long:") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment