Pandas: Merging two rows based on the date and null values

Viewed 33

I have a Python dataframe as below: enter image description here

I need to merge the rows which have the same unique ID with the below criteria:

  • Keep the data with the latest date only. If two rows have the same date, use the data which is not blank

So the output should look like enter image description here I am new to Python. I tried to use merge but could not get the result as expected.

0 Answers
Related