Given the following data frame:
a = pd.DataFrame({'A': [1,2], 'B': [4,0], 'C': [1,2]})
a
A B C
0 1 4 1
1 2 0 2
I would like to create a new column D
containing the non-null values (per row) separated by columns. Like this:
A B C D
0 1 4 1 1,4,1
1 2 0 2 1,0,2
In reality, I will have many columns. Thanks in advance!