Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用;“不在列表中”;选择中的语法_Python_Pandas - Fatal编程技术网

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)]