我有以下内容pandas df:
Name
Jack
Alex
Jackie
Susan
我还有以下命令:
d = {'Jack':['Male','22'],'Alex':['Male','26'],'Jackie':['Female','28'],'Susan':['Female','30']}
Gender我想为和添加两列,Age以便我的df回报:
Name Gender Age
Jack Male 22
Alex Male 26
Jackie Female 28
Susan Female 30
我努力了:
df['Gender'] = df.Name.map(d[0])
df['Age'] = df.Name.map(d[1])
但没有这样的运气。任何想法或帮助将不胜感激!谢谢!
慕码人2483693
梵蒂冈之花
HUX布斯
白猪掌柜的
相关分类