Tuple Comparison

前端 未结 2 548
谎友^
谎友^ 2021-01-24 21:46

I`ve a dictionary defined like this :

d = {\"date\": tuple(date),\"open\":tuple(open),\"close\":tuple(close),\"min\":tuple(min),\"max\":tuple(max),\"MA\":tuple(m         


        
2条回答
  •  Happy的楠姐
    2021-01-24 22:17

    what am I missing? d['close'] > d['MA']?

    Edit: Re, your comments

    [...] what I want to return is how many times one element of "close" is > to the matching element of MA . (same tuple index)

    sum( pair[0] > pair[1] for pair in zip(d['close'], d['MA']) )
    

提交回复
热议问题