I found similar questions but they did not solve my problem.
I have this Pandas DataFrame. The dtypes of the columns can either be str or dt, I can change this afterwards:
id_of_station measurement1 measurement2 measurement3 measurement4 measurement5
0 7 NaN NaN NaN NaN NaN
1 21 2021-04-09 2021-04-09 2021-04-09 2021-04-09 NaN
2 28 2021-04-09 2021-04-09 2021-04-09 2021-04-09 NaN
3 31 2021-04-09 2021-04-09 2021-04-09 2021-04-09 2021-04-09
4 42 2021-04-09 NaN NaN 2021-04-09 NaN
... ... ... ... ... ... ...
489 9546 NaN NaN 2021-04-09 2021-04-09 NaN
What I want is to merge the date columns together to one new column. If there is no date for the specific ID like in id_of_station 7 the Output should be NaN.
So the Output should look similar to this:
id_of_station last_measurement
0 7 NaN
1 21 2021-04-09
2 28 2021-04-09
3 31 2021-04-09
4 42 2021-04-09
... ... ...
489 9546 2021-04-09