Input:
import pandas as pd
data = [['tom', 'Delhi', 'Jaipur'], ['nick', 'Delhi', 'Delhi'], ['juli', '', 'Noida'], ['rob', 'Gurugram', ''], ['dan', '', '']]
df = pd.DataFrame(data, columns = ['Name', 'City1', 'City2'])
Name City1 City2
0 tom Delhi Jaipur
1 nick Delhi Delhi
2 juli Noida
3 rob Gurugram
4 dan
Expected Output: If values are same take any, if not the take any non-null if possible
Name City
0 tom Delhi
1 nick Delhi
2 juli Noida
3 rob Gurugram
4 dan
I tried looking for merge column here , but it didn't help in my case.
data = [['tom', 'Delhi', 'Jaipur'], ['nick', 'Delhi', 'Delhi'], ['juli', np.nan, 'Noida'], ['rob', 'Gurugram', np.nan], ['dan', np.nan, np.nan]] df = pd.DataFrame(data, columns = ['Name', 'City1', 'City2'])?