indexメソッドを利用した複数条件でdfの行を削除する 2023年5月17日 / 1 min read View more blogs with the tag python , View more blogs with the tag pandas Table of Contents #はじめに #方法 はじめに indexメソッドを利用した複数条件でdfの行を削除する方法です。 方法 # fruits列が'tomato'を含み、かつ、'orange'を含まない行を削除するdrop_index = df.index[ df['fruits'].str.contains('tomato') & ~df['fruits'].str.contains('orange') # ~は否定]df.drop(drop_index, inplace=True)