DataFrame.iterrows()を使用してDataFrameの行を繰り返し処理しています。行が特定の基準を満たしていれば、他のDataFrameに格納します。 set.difference(another_set)のように両方に表示される行を削除する方法はありますか?pd.DataFrameの一部をPythonで削除する
私は質問に答えがわからないので、私は問題を解決し、2つのDataFramesを持つ代わりに良いデータを保存して、別のDataFrameを作成しました。それら両方。
def test_right_chain(self, temp):
temp__=pd.DataFrame()
temp_=pd.DataFrame()
key=temp["nr right"].iloc[0]
temp_=temp_.append(temp.iloc[0])
temp=temp[1:]
for index, row in temp.iterrows():
print row
key_=row['nr right']
if abs(key_-key)==1:
pass
elif len(temp_)>2:
print row
temp__.append(temp_)
temp_=pd.DataFrame()
else:
temp_=pd.DataFrame()
temp_=temp_.append(row)
key=key_
return temp__
問題を再現して助けてくれるように、入力コードの少なくとも一部と予想される出力を投稿する必要があります。 –
__text__形式で5-7行のサンプル入力データセットと期待される出力を提供すると – MaxU