fork download
  1. import pandas as pd
  2. def times(x):
  3. return 2*x
  4. df=pd.DataFrame({'c1':[1,2,3,4],'c2':[11,22,33,11],'c3':['a','b','c','d']})
  5. print(df['c1'].apply(times))
  6. print(df)
Success #stdin #stdout 0.46s 60844KB
stdin
Standard input is empty
stdout
0    2
1    4
2    6
3    8
Name: c1, dtype: int64
   c1  c2 c3
0   1  11  a
1   2  22  b
2   3  33  c
3   4  11  d