Skip to content
Advertisement

Join multiple columns into one column

Lets say I have pandas data frame like this:

JavaScript

What I would like to have is:

JavaScript

I tried using apply and join as below but not getting the output as I wish:

JavaScript

How can I get output that I want by modifying above code. Thank in advance.

Edit: I am looking solution using above code to get the expected output. Although codes in answers using bfill and row-wise max are nice, they don’t work well on the large data that I have.

Advertisement

Answer

We can using bfill

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement