Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/350.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 使用bool()结果生成列表_Python_Pandas_Boolean - Fatal编程技术网

Python 使用bool()结果生成列表

Python 使用bool()结果生成列表,python,pandas,boolean,Python,Pandas,Boolean,我需要比较以下索引 index_1=(df[number:,1] > high_value).argmax() index_2=(df[number:,0] < low_value).argmax() index_1=(df[number:,1]>高值)。argmax() 索引_2=(df[number:,0]index\u sl),它将返回该语句是真还是假。我在这里试图实现的是,每当我在数字中添加1时,就建立一个包含所有真与假的列表。如何建立此列表?可能是这样的(假设您希望n

我需要比较以下索引

index_1=(df[number:,1] > high_value).argmax() 
index_2=(df[number:,0] < low_value).argmax() 
index_1=(df[number:,1]>高值)。argmax()
索引_2=(df[number:,0]<低值)。argmax()
如果我运行
bool(index\u tp>index\u sl)
,它将返回该语句是真还是假。我在这里试图实现的是,每当我在
数字中添加1时,就建立一个包含所有真与假的列表。如何建立此列表?

可能是这样的(假设您希望
number
df
的第一行到最后一行运行):

your_list=[(df[number:,1]>高值)。argmax()>
(df[number:,0]<低_值).argmax()
对于范围内的数字(0,df.shape[0])]

就是这样!不幸的是,这种方法比我使用的atm慢得多。但是,嘿,还是很重要。谢谢!
your_list = [ (df[number:,1] > high_value).argmax() >
              (df[number:,0] < low_value).argmax()
              for number in range(0, df.shape[0]) ]