indexメソッドを利用した複数条件でdfの行を削除する2023/5/17 / 1 min readView more blogs with the tag python, View more blogs with the tag pandasTable 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)