Skip to content

Instantly share code, notes, and snippets.

@ryantuck
Created January 27, 2016 02:19
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 ryantuck/13481772c94a2a91dde7 to your computer and use it in GitHub Desktop.
Save ryantuck/13481772c94a2a91dde7 to your computer and use it in GitHub Desktop.
import pandas as pd
data = [
[1,2],
[3,4],
[5,6]
]
cols = ['a','b']
df = pd.DataFrame(data,columns=cols)
print df
def my_fn(x,y):
return x*y
l = list(df['a'])
tmp = []
for x in l:
tmp.append(my_fn(3,x))
df['a'] = pd.Series(tmp, index=df.index)
print df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment