我有一个如下所示的df:
Day ID1 ID2 Pt1 C0 DE Pt1 C0 DS Pt1 C1 DE Pt1 C1 DS ID
7 34 Pre-1 16 NaN NaN NaN NaN Pre-1 16
78 34 Pre-1 16 0 6 0 2 Pre-1 16
8 17 Pre-1 88 NaN NaN NaN NaN Pre-1 88
78 17 Pre-1 88 0 8 0 0 Pre-1 88
8 21 Pre-1 6 NaN NaN NaN NaN Pre-1 6
88 21 Pre-1 6 2 1 5 4 Pre-1 6
以前,对于具有更高NaN
值的行,ID2列为Day
。我使用groupby
和bfill
的组合来填充这些内容。但是,我不知道如何删除主要包含NaN
值的行。
我想要一个像这样的df:
Day ID1 ID2 Pt1 C0 DE Pt1 C0 DS Pt1 C1 DE Pt1 C1 DS ID
78 34 Pre-1 16 0 6 0 2 Pre-1 16
78 17 Pre-1 88 0 8 0 0 Pre-1 88
88 21 Pre-1 6 2 1 5 4 Pre-1 6
我发现的大多数类似drop_duplicates
的函数似乎都不起作用,因为即使我填写了所有值,由于{{1 }}值。