Skip to content

Instantly share code, notes, and snippets.

@Everfighting
Created February 4, 2021 08:12
Show Gist options
  • Save Everfighting/020d58c67ec5cc986ae6b2f7186db7ca to your computer and use it in GitHub Desktop.
Save Everfighting/020d58c67ec5cc986ae6b2f7186db7ca to your computer and use it in GitHub Desktop.
s=pd.Series([11,12,13],name='S')
data=np.arange(21,24)
df=pd.DataFrame({'A':[31,32,33],'B':[41,42,43]})
fun=lambda x:x.A+x.B
df.assign(C=fun,D=df.A+df.B,E=s,F=data)#增加新列
A B C D E F
0 31 41 72 72 11 21
1 32 42 74 74 12 22
2 33 43 76 76 13 23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment