Move Up columns DataFrame Pandas to where rows match
Solution 1:
For #2, if I understand correctly, you have multiple rows for the same time
values such that either the first, second or last 2 temp columns are populated and the remaining are nulls. And you want to squish the df such that you don't have multiple records for the same time
value and all temp columns are populated for each row.
If that is the case, the following approach might work:
- Create three df subsets like this:
- One with only the first temp column (out of 4 temp columns) and all the other columns.
- One with only the second temp column and all the other columns.
- One with only the last 2 temp columns and all the other columns.
- For all three dfs, drop rows where the temp column in that df is null.
- Join the resulting dfs on time.