Adding new column to existing DataFrame in Python pandas

后端 未结 25 1685
你的背包
你的背包 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:31

    If the column you are trying to add is a series variable then just :

    df["new_columns_name"]=series_variable_name #this will do it for you
    

    This works well even if you are replacing an existing column.just type the new_columns_name same as the column you want to replace.It will just overwrite the existing column data with the new series data.

提交回复
热议问题