Python 使用;“不在列表中”;选择中的语法
我正在尝试做一些类似的事情Python 使用;“不在列表中”;选择中的语法,python,pandas,Python,Pandas,我正在尝试做一些类似的事情 exclude_values = range(low, high) # for the sake of example df = df[df['blah'] not in exclude_values] 这只是提出了“一系列的真值是模糊的”例外。问题是,我看不出如何更改此语法,以便不在中使用not。我遗漏了什么(可能是非常明显的)东西?使用isin df[~df['blah'].isin(exclude_values)] 使用惯用方法和按位逻辑: df = df
exclude_values = range(low, high) # for the sake of example
df = df[df['blah'] not in exclude_values]
这只是提出了“一系列的真值是模糊的”例外。问题是,我看不出如何更改此语法,以便不在中使用not。我遗漏了什么(可能是非常明显的)东西?使用isin
df[~df['blah'].isin(exclude_values)]
使用惯用方法和按位逻辑:
df = df[~round(df.blah).isin(exclude_values)]