I have the dataframe, that needs to put the not null values into the column.
For example: there maybe more than 5 columns, but no more than 2 not null values each rows
df1 = pd.DataFrame({'A' : [np.nan, np.nan, 'c',np.nan, np.nan, np.nan],
'B' : [np.nan, np.nan, np.nan, 'a', np.nan,'e'],
'C' : [np.nan, 'b', np.nan,'f', np.nan, np.nan],
'D' : [np.nan, np.nan, 'd',np.nan, np.nan, np.nan],
'E' : ['a', np.nan, np.nan,np.nan, np.nan, 'a']})
A B C D E
NaN NaN NaN NaN a
NaN NaN b NaN NaN
c NaN NaN d NaN
NaN a f NaN NaN
NaN NaN NaN NaN NaN
NaN e NaN NaN a
My expected output: To generate 4 new columns, Other_1; Other_1_name; Other_2; Other_2_name, the value will go to Other_1 or Other_2 if there are not null values, and the column name will go to Other_1_name or Other_2_name. if the value is NaN leave the 4 column rows NaN.
A B C D E Other_1 Other_1_name Other_2 Other_2_name
NaN NaN NaN NaN a a E NaN NaN
NaN NaN b NaN NaN b C NaN NaN
c NaN NaN d NaN c A d D
NaN a f NaN NaN a B f C
NaN NaN NaN NaN NaN NaN NaN NaN NaN
NaN e NaN NaN a e B a E