How to remove nan value while combining two column in Panda Data frame?

前端 未结 3 1696
萌比男神i
萌比男神i 2020-11-30 03:59

I am trying but not able to remove nan while combining two columns of a DataFrame.

Data is like:

feedback_id                        


        
3条回答
  •  眼角桃花
    2020-11-30 04:30

    If you want a solution that doesn't require referencing df twice or any of its columns explicitly:

    df.bfill(axis=1).iloc[:, 0]
    

    With two columns, this will copy non-null values from the right column into the left, then select the left column.

提交回复
热议问题