Adding new column to existing DataFrame in Python pandas

后端 未结 25 1718
你的背包
你的背包 2020-11-22 01:15

I have the following indexed DataFrame with named columns and rows not- continuous numbers:

          a         b         c         d
2  0.671399  0.101208 -         


        
25条回答
  •  南旧
    南旧 (楼主)
    2020-11-22 01:28

    It seems that in recent Pandas versions the way to go is to use df.assign:

    df1 = df1.assign(e=np.random.randn(sLength))

    It doesn't produce SettingWithCopyWarning.

提交回复
热议问题