Skip to content

Instantly share code, notes, and snippets.

@h3ik0th
Created October 6, 2022 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h3ik0th/a273aecf3d5672b47d31e2eac7acb474 to your computer and use it in GitHub Desktop.
Save h3ik0th/a273aecf3d5672b47d31e2eac7acb474 to your computer and use it in GitHub Desktop.
%%time
# apply, but pre-select columns e and f instead of complete rows: iteration misdemeanor
def myfunc4(b, c):
x = (b + c)**2
y = (b - c)**2
z = (b - c)**2
return x, y,z
dfY = pd.DataFrame()
dfY[["x", "y", "z"]] = dfS.apply(lambda x: myfunc4(x["B"], x["C"]), axis=1, result_type="expand")
display(dfY.tail())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment