0
所以我有一個數據框,我將它分組,然後對其應用一個函數。現在我想檢查框架中的每一行,檢查數據框中的其餘行是否符合某些條件,我希望將它們添加到具有某種標籤的不同數據框中,並將其從原始列表中刪除。如果它不通過條件,我保留那裏的行並移動到下一行。迭代Dataframe中的行並將其與其餘行進行比較
如
time status number action fname lname
0 10.30 Active 2 0 Adrian Peter
1 11.01 Active 3 2 Peter Thomas
2 11.05 Passive 2 0 Thomas Adrian
3 11.07 Passive 2 1 Jen Anniston
,所以我這樣做
df.groupby(status).apply(f)
def f(x):
I want to perform some tasks here and with the remaining dataframe
i want to see if index 0 has similar number and action in the
remaining data frame. If true i want to put this in a different dataframe and tag it and remove the pair from the origial df.
I want to then move on to the next index and do the same. If false after looking at all the data in the frame i want to delete this from the original df too
如果您爲輸入示例添加一些示例輸出,可能會更容易一些。 – miradulo