0
データフレームがあります。これはグループ化してから関数を適用しています。今、私は、フレーム内の各行をチェックしたいのですが、データフレームの残りの行と照合し、いくつかの条件に合致すれば、それらを別のデータフレームに追加して元のタグから削除したいと思います。それは条件を渡さない場合は、私はそこに行を維持し、次の行に移動します。データフレームの行を繰り返し処理し、それを残りの行と比較します。
例えば
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
ので、私はあなたの希望の関数(f)は副作用を持っている場合
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