Skip to content

Instantly share code, notes, and snippets.

@grayskripko
Created February 15, 2022 10:51
Show Gist options
  • Save grayskripko/27654e59094cb7cd83908b102ad14369 to your computer and use it in GitHub Desktop.
Save grayskripko/27654e59094cb7cd83908b102ad14369 to your computer and use it in GitHub Desktop.
Pandas .pipe() .apply() .transform() .map()
def inve(x):
print(type(x), x)
s = pd.Series([1,2,3])
s.pipe(inve) # series
s.apply(inve) # int 1
s.transform(inve) # int 1
s.map(inve) # int 1
df = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]})
df.pipe(inve) # df
df.apply(inve) # series
df.transform(inve) # series
df.applymap(inve) # int 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment