I have a table like this:
|-----|-----|-----|
|  A  |  B  |  C  |
|-----|-----|-----|
|     |  5  |     |
|-----|-----|-----|
|  1  |     |     |
|-----|-----|-----|
|     |  5  |     |
|-----|-----|-----|
|     |     |  2  |
|-----|-----|-----|
|     |     |  2  |
|-----|-----|-----|
where each column in the desired range has only one integer in its row. I want to merge these columns into a single new column that would look like this:
|-----|-----|-----|    |-----|
|  A  |  B  |  C  |    |  Z  |
|-----|-----|-----|    |-----|
|     |  5  |     | →  |  5  |
|-----|-----|-----|    |-----|
|  1  |     |     | →  |  1  |
|-----|-----|-----|    |-----|
|     |  5  |     | →  |  5  |
|-----|-----|-----|    |-----|
|     |     |  2  | →  |  2  |
|-----|-----|-----|    |-----|
|     |     |  2  | →  |  2  |
|-----|-----|-----|    |-----|
I have been searching, but the closest solution I can find is doing something like:
df.iloc[:,some_column:another_column].apply( lambda x: "".join(x.astype(str)), axis=1)
However, this also concatenates "NaN"s from the blank cells, which is obviously undesirable.
How might I get my desired output?
 
     
    