基于user1827356的答案,您可以使用
df.merge以下命令一口气完成分配:
df.merge(df.textcol.apply(lambda s: pd.Series({'feature1':s+1, 'feature2':s-1})), left_index=True, right_index=True) textcol feature1 feature20 0.772692 1.772692 -0.2273081 0.857210 1.857210 -0.1427902 0.065639 1.065639 -0.9343613 0.819160 1.819160 -0.1808404 0.088212 1.088212 -0.911788
编辑: 请注意巨大的内存消耗和低速:https : //ys-l.github.io/posts/2015/08/28/how-not-to-use-
pandas-apply/!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)