pandas: combine two columns in a DataFrame

后端 未结 5 510
感情败类
感情败类 2020-11-30 07:42

I have a pandas DataFrame that has multiple columns in it:

Index: 239897 entries, 2012-05-11 15:20:00 to 2012-06-02 23:44:51
Data columns:
foo           


        
5条回答
  •  难免孤独
    2020-11-30 08:17

    You can do this using numpy too.

    df['bar'] = np.where(pd.isnull(df['bar']),df['foo'],df['bar'])

提交回复
热议问题